public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43720]  New: undefined reference to static const integral template class member
@ 2010-04-11 19:10 roman at binarylife dot net
  2010-04-11 19:22 ` [Bug c++/43720] undefined reference to static const integral " rguenth at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: roman at binarylife dot net @ 2010-04-11 19:10 UTC (permalink / raw)
  To: gcc-bugs

$ 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


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

* [Bug c++/43720] undefined reference to static const integral class member
  2010-04-11 19:10 [Bug c++/43720] New: undefined reference to static const integral template class member roman at binarylife dot net
@ 2010-04-11 19:22 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-11 19:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-04-11 19:22 -------
You need a proper definition for the constant.


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/43720] undefined reference to static const integral class member
  2010-04-11 19:10 [Bug c++/43720] New: undefined reference to static const integral template class member roman at binarylife dot net
  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
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-04-12 11:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from redi at gcc dot gnu dot org  2010-04-12 11:06 -------
dup of Bug 42101 and Bug 14404 and Bug 38624 and Bug 37175 etc. etc.


-- 


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


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

* [Bug c++/43720] undefined reference to static const integral class member
  2010-04-11 19:10 [Bug c++/43720] New: undefined reference to static const integral template class member roman at binarylife dot net
  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
  2 siblings, 0 replies; 4+ messages in thread
From: roman at binarylife dot net @ 2010-04-12 12:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from roman at binarylife dot net  2010-04-12 12:41 -------
sorry for bothering :)
thanks


-- 


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


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

end of thread, other threads:[~2010-04-12 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-11 19:10 [Bug c++/43720] New: undefined reference to static const integral template class member roman at binarylife dot net
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

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