public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52807] New: static constant member variable undefined
@ 2012-03-31 12:37 sidney.cadot at gmail dot com
  2012-03-31 12:56 ` [Bug c++/52807] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: sidney.cadot at gmail dot com @ 2012-03-31 12:37 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52807
           Summary: static constant member variable undefined
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sidney.cadot@gmail.com


The following program compiles but does not link on Linux, g++ 4.6.1, when
compiled with -O0.

$ g++ -O0 showbug.cc -o showbug
/tmp/ccUq3Hog.o: In function `main':
showbug.cc:(.text+0x16): undefined reference to `Foo::FooConstant'
collect2: ld returned 1 exit status

Compiling with any higher optimization level makes the link error disappear.


/////////////////////////// start

#include <iostream>

bool b()
{
    return true;
}

struct Foo
{
    static const int FooConstant = 123;
};

int main()
{
    std::cout << (b() ? Foo::FooConstant : Foo::FooConstant) << std::endl;
    return 0;
}

/////////////////////////// end


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/52807] static constant member variable undefined
  2012-03-31 12:37 [Bug c++/52807] New: static constant member variable undefined sidney.cadot at gmail dot com
@ 2012-03-31 12:56 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-31 12:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-31 12:37:20 UTC ---
http://gcc.gnu.org/wiki/VerboseDiagnostics#undefined_reference_to_.60S::a.27


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-31 12:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-31 12:37 [Bug c++/52807] New: static constant member variable undefined sidney.cadot at gmail dot com
2012-03-31 12:56 ` [Bug c++/52807] " redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).