[cfe-dev] Injected class name

Renato Golin renato.golin at arm.com
Mon Jun 14 07:27:01 PDT 2010


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100614/0fa13ca2/attachment.html>


More information about the cfe-dev mailing list