This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/33876] in-class initialization of const static data members and template functions



------- Comment #2 from michael dot zillich at gmx dot net  2007-10-23 23:43 -------
(In reply to comment #1)
> And this is correct behavior. The C++ standard says they have to be declared
> still, you just have a definition.

Ok, got You.

But then why the different bahaviour for
a) optimization turned on/off
b) if the arguments are not passed with references (the function mux() in my
example)
I suspect that if I do not actually define it, the compiler will just
substitute any occurcnce of say A::x with the literal value 1. And of course
this fails as soon as I need a reference to A::x

In any case I would expect an undefined reference reported in all cases. Or a
warning, at least with -Wall.
As it is now the compiler behaviour is a bit unclear, not complaining in one
case, correctly reporting error in the other case.
Personally I am all for strict adherence to standards.

(Thanks for the lightning-fast answer by the way! :)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33876


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]