[Bug c++/45082] Static const signed int class member causes undefined symbol.
redi at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Jul 26 16:33:00 GMT 2010
------- Comment #3 from redi at gcc dot gnu dot org 2010-07-26 16:32 -------
(In reply to comment #2)
> The bug/feature may be that re-typing BUFF_SIZE to static const unsigned int
> allows the compiler to not report a problem.
You're not "re-typing" it, you're providing a definition for a variable that
was previously only declared, not defined.
> It doesn't require a const
> unsigned myclass::BUFF_SIZE; anywhere
Yes it does, it requires it where you bind a reference to the variable.
If you only want it to be used as an integral constant, don't use it in a
context that requires a variable (e.g. reference binding)
> and still compiles when it shouldn't.
There are dozens of (invalid) bug reports in bugzilla about this, feel free to
search for more details.
The compiler must not reject your program as it doesn't know until link time
that you've failed to define the symbol. It could be defined in some other
object or library that you link to later.
The bug was in your program, not the compiler.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45082
More information about the Gcc-bugs
mailing list