This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++-2.95.2/DEC OSF fails to implicitly instantiate explicitly initialized static POD data of a class template
- To: gcc bug reports <gcc-bugs at gcc dot gnu dot org>
- Subject: g++-2.95.2/DEC OSF fails to implicitly instantiate explicitly initialized static POD data of a class template
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Mon, 03 Jul 2000 13:25:48 -0600
- Organization: Rogue Wave Software, Inc.
Hi,
g++ 2.95.2 doesn't implicitly instantiate S<char>::b below on DEC OSF1
5.0. Removing the explicit initializer or explicitly instantiating the
template works. Could this have something to do with the bug (that g++
warns about on DEC) that causes multiple copies of explicitly
initialized static local data in inline code to be emitted?
Thanks
Martin
$ cat test.cpp
template <class T>
struct S
{
static T a;
static T b;
};
template <class T>
T S<T>::a; // <-- NOT initialized
template <class T>
T S<T>::b = 0; // <-- explicitly initialized
int main ()
{
return S<char>::a + S<char>::b;
}
$ g++ -v test.cpp
Reading specs from
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/cpp
-lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus
-Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__
-D__osf__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix
-D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -D__EXCEPTIONS
-D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C -Acpu(alpha)
-Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev5__ -Acpu(ev5)
-D__alpha_bwx__ -Acpu(bwx) test.cpp /tmp/ccp72nrk.ii
GNU CPP version 2.95.2 19991024 (release)
#include "..." search starts here:
#include <...> search starts here:
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3
/usr/local/include
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../alphaev56-dec-osf4.0d/include
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search
path:
End of omitted list.
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/cc1plus
/tmp/ccp72nrk.ii -quiet -dumpbase test.cc -version -o /tmp/ccGxcBFv.s
GNU C++ version 2.95.2 19991024 (release) (alphaev56-dec-osf4.0d)
compiled by GNU C version 2.95.2 19991024 (release).
as -g -nocpp -O0 -o /tmp/ccfVdVVH.o /tmp/ccGxcBFv.s
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/mips-tfile
-v -o /tmp/ccfVdVVH.o /tmp/ccGxcBFv.s
mips-tfile version 2.95.2 19991024 (release)
/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/collect2
-G 8 -O1 -call_shared /usr/lib/cmplrs/cc/crt0.o
-L/package/1/V5.0/compilers/g++/2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2
-L/usr/lib/cmplrs/cc -L/package/1/V5.0/compilers/g++/2.95.2/lib
/tmp/ccfVdVVH.o -lstdc++ -lm -lgcc -lc -lgcc
/usr/bin/ld:
Unresolved:
S<char>::b
collect2: ld returned 1 exit status