This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Please look at the following source file:
//----------------------------- Source file START---------------------------
//test.cpp
#include <iostream.h>
template <class SomeType>
class sclass {
protected:
static bool updated;
SomeType data;
public:
void setit(const SomeType &d) { data = d;
}
void printit(void)
{ if (updated) cout << data
<< endl; else cout << "Not Updated\n"; }
};
template <class SomeType>
bool sclass<SomeType>::updated = true;
int main(void)
{
sclass<int> i;
i.setit(5);
i.printit();
return 0;
}
//----------------------------- Source file END---------------------------
I realize that this code doesn't do anything useful. I have trimmed it down to the absolute basics to demonstrate the problem. Notice that the compiler does not allocate space for the static variable of this templated class.
DEMONASTRATION UNDER HPUX 10.20 and egcs 1.1.2 where it doesn't work:
cda100:/users/bfs1000/kom/dev> uname -a
HP-UX cda100 B.10.20 A 9000/735 2009529265 two-user license
cda100:/users/bfs1000/kom/dev> /usr/local/hppa1.1-hp-hpux10.20/bin/as
--version
GNU assembler 2.9.1
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the
terms of
the GNU General Public License. This program has absolutely
no warranty.
This assembler was configured for a target of `hppa1.1-hp-hpux10.20'.
cda100:/users/bfs1000/kom/dev> nm --version
GNU nm 2.9.1
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the
terms of
the GNU General Public License. This program has absolutely
no warranty.
cda100:/users/bfs1000/kom/dev> g++ -v -Wall -c -o test-hpux.o
test.cpp
Reading specs from /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-Dhppa -Dhp9000s800 -D__hp9000s800 -Dhp9k8 -DPWB -Dhpux -Dunix -D__hppa__
-D__hp9000s800__ -D__hp9000s800 -D__hp9k8__ -D__PWB__ -D__hpux__ -D__unix__
-D__hppa -D__hp9000s800 -D__hp9k8 -D__PWB -D__hpux -D__unix -Asystem(unix)
-Asystem(hpux) -Acpu(hppa) -Amachine(hppa) -D__EXCEPTIONS -Wall -D__hp9000s700
-D_PA_RISC1_1 -D_HPUX_SOURCE -D_HIUX_SOURCE test.cpp /var/tmp/cczQ1l4R.ii
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (hppa)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++
/usr/local/include
/usr/local/hppa1.1-hp-hpux10.20/include
/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/cc1plus
/var/tmp/cczQ1l4R.ii -quiet -dumpbase test.cc -Wall -version -o /var/tmp/ccI8ah9U.s
GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release) (hppa1.1-hp-hpux10.20)
compiled by GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release).
/usr/local/hppa1.1-hp-hpux10.20/bin/as -o test-hpux.o /var/tmp/ccI8ah9U.s
cda100:/users/bfs1000/kom/dev> g++ -v -Wall -o test-hpux test-hpux.o
Reading specs from /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66/collect2
-L/lib/pa1.1 -L/usr/lib/pa1.1 -z -u main -o test-hpux /usr/ccs/lib/crt0.o
-L/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/egcs-2.91.66 -L/usr/local/hppa1.1-hp-hpux10.20/lib
-L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib test-hpux.o -lstdc++ -lm
-lgcc -lc -lgcc
/usr/ccs/bin/ld: Unsatisfied symbols:
sclass<int>::updated (data)
collect2: ld returned 1 exit status
cda100:/users/bfs1000/kom/dev> nm test-hpux.o | grep sclass
U _t6sclass1Zi$updated
00000000 t printit__t6sclass1Zi
00000000 t setit__t6sclass1ZiRCi
cda100:/users/bfs1000/kom/dev> nm -C test-hpux.o | grep sclass
U sclass<int>::updated
00000000 t sclass<int>::printit(void)
00000000 t sclass<int>::setit(int const &)
DEMONASTRATION UNDER Linux and egcs 1.1.2 where it does work:
pc33:/users/bfs1000/kom/dev$ uname -a
Linux pc33 2.0.36 #6 Mon Mar 22 11:55:39 CST 1999 i686 unknown
pc33:/users/bfs1000/kom/dev$ /usr/i586-pc-linux-gnulibc1/bin/as
--version
GNU assembler 980303
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the
terms of
the GNU General Public License. This program has absolutely
no warranty.
This assembler was configured for a target of `i586-linux'.
pc33:/users/bfs1000/kom/dev$ nm --version
GNU nm 980303
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the
terms of
the GNU General Public License. This program has absolutely
no warranty.
pc33:/users/bfs1000/kom/dev$ g++ -v -Wall -c -o test-linux.o
test.cpp
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.66/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__
-D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix) -D__EXCEPTIONS
-Wall -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__
-Di586 -Dpentium -D__i586 -D__i586__ -D__pentium -D__pentium__ test.cpp
/tmp/ccLZrRPd.ii
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/qt/include
/usr/local/qt/include
/usr/include/g++
/usr/lib/g++-include
/usr/local/include
/usr/i586-pc-linux-gnulibc1/include
/usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.66/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.66/cc1plus
/tmp/ccLZrRPd.ii -quiet -dumpbase test.cc -Wall -version -o /tmp/ccShgOGm.s
GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i586-pc-linux-gnulibc1)
compiled by GNU C version egcs-2.91.66 19990314 (egcs-1.1.2 release).
/usr/i586-pc-linux-gnulibc1/bin/as -V -Qy -o test-linux.o
/tmp/ccShgOGm.s
GNU assembler version 980303 (i586-linux), using BFD version 2.8.1.0.23
pc33:/users/bfs1000/kom/dev$ nm test-linux.o | grep sclass
00000000 W _t6sclass1Zi.updated
00000000 W printit__t6sclass1Zi
00000000 W setit__t6sclass1ZiRCi
pc33:/users/bfs1000/kom/dev$ nm -C test-linux.o | grep sclass
00000000 W sclass<int>::updated
00000000 W sclass<int>::printit(void)
00000000 W sclass<int>::setit(int const &)
Thankyou for your attention to this matter.
-- Jose Santiago Senior Systems Analyst - Scientific Systems Komatsu Mining Systems - Peoria Operations 2300 N.E. Adams Street P.O. Box 240 Peoria, IL 61650-0240 Voice:309-672-7325 Fax:309-672-7753 mailto:jose@haulpak.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |