Injected class name

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Injected class name

Renato Golin-3

Hi,

 

Why does clang refuse this case?

 

Looks like it still thinks that *p is opaque at the object definition, when it’s not.

 

class Class {

public:

        Class *p;

  int i;

        Class(int a) : p(0), i(a) {}

};

const class Class &object = 0;

 

/*

$ clang -c injected.cpp

injected.cpp:7:29: error: cannot compile this global variable that binds reference to a non-lvalue yet

const class Class &object = 0;

                            ^

1 error generated.

*/

 

As far as I understand, chapter 9 (paragraph 2) of the (C++03) standard allows you to do that. Other compilers, such as G++, understand it without problems.

 

Cheers,

--renato


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Injected class name

Douglas Gregor
<base href="x-msg://95/">
On Jun 14, 2010, at 7:27 AM, Renato Golin wrote:

Hi,
 
Why does clang refuse this case?
 
Looks like it still thinks that *p is opaque at the object definition, when it’s not.
 
class Class {
public:
        Class *p;
  int i;
        Class(int a) : p(0), i(a) {}
};
const class Class &object = 0;
 
/*
$ clang -c injected.cpp
injected.cpp:7:29: error: cannot compile this global variable that binds reference to a non-lvalue yet
const class Class &object = 0;
                            ^
1 error generated.
*/
 
As far as I understand, chapter 9 (paragraph 2) of the (C++03) standard allows you to do that. Other compilers, such as G++, understand it without problems.

This is a known bug. See


- Doug

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Injected class name

Sebastian Redl
In reply to this post by Renato Golin-3

On Mon, 14 Jun 2010 15:27:01 +0100, "Renato Golin" <[hidden email]>
wrote:

>
> Why does clang refuse this case?
>
> $ clang -c injected.cpp
>
> injected.cpp:7:29: error: cannot compile this global variable that binds
> reference to a non-lvalue yet
>
> const class Class &object = 0;
>
>                             ^
>
> 1 error generated.
>
> As far as I understand, chapter 9 (paragraph 2) of the (C++03) standard
> allows you to do that. Other compilers, such as G++, understand it
without
> problems.
>

I direct your attention to the word "yet" in the error message. In other
words, it's simply something that isn't yet implemented. Or perhaps it
would actually work, but we forgot to remove the error message.

Sebastian

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Injected class name

Renato Golin
On 14 June 2010 20:34, Sebastian Redl <[hidden email]> wrote:
> I direct your attention to the word "yet" in the error message. In other
> words, it's simply something that isn't yet implemented. Or perhaps it
> would actually work, but we forgot to remove the error message.

I see, I thought the "yet" was about the type still being incomplete,
not unimplemented feature. ;)

I'll play with it a bit...

cheers,
--renato
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev