http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47396
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-21 13:49:32 UTC --- GCC bugzilla is not a place to learn C++, just read the standard, in particular [class.static.data]/4: "If a static data member is of const integral or const enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression (5.19). In that case, the member can appear in integral constant expressions within its scope. The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition shall not contain an initializer." --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-01-21 13:49:32 UTC --- (In reply to comment #2) > but like this: > > struct test > { > static const int i = 0; > }; > > int main(void) > { > const unsigned int &m = test::i; > } > > > no link errors!!!! why??? a temporary (of type unsigned) has to be created, and the reference binds to the temporary, not to test::i This is invalid, please don't reopen it