This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33876] in-class initialization of const static data members and template functions
- From: "michael dot zillich at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Oct 2007 23:43:10 -0000
- Subject: [Bug c++/33876] in-class initialization of const static data members and template functions
- References: <bug-33876-15253@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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