This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45082] Static const signed int class member causes undefined symbol.
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jul 2010 16:32:50 -0000
- Subject: [Bug c++/45082] Static const signed int class member causes undefined symbol.
- References: <bug-45082-19484@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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