This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13915] New: Initialization of static template members
- From: "japple at freeshell dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jan 2004 04:08:42 -0000
- Subject: [Bug c++/13915] New: Initialization of static template members
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#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