public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "roman at binarylife dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/43720] New: undefined reference to static const integral template class member Date: Sun, 11 Apr 2010 19:10:00 -0000 [thread overview] Message-ID: <bug-43720-17259@http.gcc.gnu.org/bugzilla/> (raw) $ cat test1.cpp template<typename X> void zzz(X const& x) { return; } struct ttt_t { static int const static_const_int=0; int func()const { zzz(static_const_int); return 0; } }; int main() { return ttt_t().func(); } $ g++ -O test1.cpp --save-temps #no errors $ g++ test1.cpp --save-temps test1.o: In function `ttt_t::func() const': test1.cpp:(.text._ZNK5ttt_t4funcEv[ttt_t::func() const]+0xd): undefined reference to `ttt_t::static_const_int' collect2: ld returned 1 exit status $ grep 'static_const_int' test1.s movl $_ZN5ttt_t16static_const_intE, %edi $ cat test2.cpp template<typename X> void __attribute((noinline)) zzz(X const& x) { static bool volatile junk=false; if (junk) zzz(x); return; } struct ttt_t { static int const static_const_int=0; int func()const { zzz(static_const_int); return 0; } }; int main() { return ttt_t().func(); } $ g++ -O3 test2.cpp --save-temps #no errors $ g++ -O2 test2.cpp --save-temps test2.o: In function `main': test2.cpp:(.text+0x5): undefined reference to `ttt_t::static_const_int' collect2: ld returned 1 exit status $ grep 'static_const_int' test2.s movl $_ZN5ttt_t16static_const_intE, %edi 4.4.4 has same issues except that -O3 fails with test2.cpp -- Summary: undefined reference to static const integral template class member Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: roman at binarylife dot net GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43720
next reply other threads:[~2010-04-11 19:10 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-04-11 19:10 roman at binarylife dot net [this message] 2010-04-11 19:22 ` [Bug c++/43720] undefined reference to static const integral " rguenth at gcc dot gnu dot org 2010-04-12 11:07 ` redi at gcc dot gnu dot org 2010-04-12 12:41 ` roman at binarylife dot net
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-43720-17259@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).