[Bug c++/13915] New: Initialization of static template members
japple at freeshell dot org
gcc-bugzilla@gcc.gnu.org
Thu Jan 29 04:08:00 GMT 2004
#include <iostream>
template<typename T>
struct wrap {
static T joe;
};
template<typename T>
T wrap<T>::joe;
struct call_out {
int num;
call_out() : num(77) {}
};
template<typename T>
struct check_call {
check_call() {
std::cout << wrap<T>::joe.num << std::endl;
}
};
check_call<call_out> x;
int main(){}
should print 77, I think, by 14.7.1/1, which says says:
"... in particular, the initialization (and any associated side effects)
of a static data member does not occur unless the static data member is
itself used in a way that requires the definition of the static data
member to exist."
--
Summary: Initialization of static template members
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: japple at freeshell dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: linux x86
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13915
More information about the Gcc-bugs
mailing list