public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Static definition error in gcc-3.4.2?
@ 2004-12-01  0:38 Shawn Edwards
  0 siblings, 0 replies; only message in thread
From: Shawn Edwards @ 2004-12-01  0:38 UTC (permalink / raw)
  To: gcc-help; +Cc: Edwards Shawn

gcc-3.4.2 seems to have problems with some static 
definitions/initializations
on Mac OSX (I am running on Mac OSX 10.3.6, Darwin 7.6.0, 
cctools-528.5).  For
instance, the static data member in the template Foo in the following 
code
snippet is always undefined.
-----------------------------------------------------------
#include <cassert>

template<class TYPE>
struct Foo {
     static int s;
};

template<class TYPE>
int Foo<TYPE>::s = sizeof(TYPE);

int main()
{
     assert(sizeof(char) == Foo<char>::s);
     assert(sizeof(int) == Foo<int>::s);
     return 0;
}
-----------------------------------------------------------
$ g++ foo.cpp
/usr/bin/ld: Undefined symbols:
Foo<char>::s
Foo<int>::s
collect2: ld returned 1 exit status
-----------------------------------------------------------
$ as -v
Apple Computer, Inc. version cctools-528.5~obj, GNU assembler version 
1.38
-----------------------------------------------------------

The gcc 3.3 that Apple shipped with my box compiles, links, and runs 
this just
fine, as does gcc 3.4.2 on Linux and Solaris.  Does anyone know what the
problem might be?  Any suggestions would be greatly appreciated.

Shawn
shawne@optonline.net

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-12-01  0:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01  0:38 Static definition error in gcc-3.4.2? Shawn Edwards

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