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++/45082] Static const signed int class member causes undefined symbol.



------- 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


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