From 7107693527355111456
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,8adc33f2feceff90,start
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,8adc33f2feceff90,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1993-05-16 13:23:57 PST
Xref: gmd.de comp.std.c++:2507 comp.lang.c++:22157
Newsgroups: comp.std.c++,comp.lang.c++
Path: gmd.de!ira.uka.de!sol.ctr.columbia.edu!caen!batcomputer!cornell!moudgill
From: moudgill@cs.cornell.edu ( Mayan Moudgill)
Subject: Template static variable member initialization
Message-ID: <1993May16.200428.7634@cs.cornell.edu>
Organization: Cornell Univ. CS Dept, Ithaca NY 14853
Distribution: usa
Date: Sun, 16 May 1993 20:04:28 GMT
Lines: 25

I was wondering wether the following was legal:
/* Templ.H */
template <class T> class Templ {
   static int _init;
}

/* Templ.C */
template <class T> Templ::_init = 0;

In cfront3.0.1, it is compiled and seems to work ok.
However, it turns out that the _init is actually initialized
different numbers of times, depending on where the class
is specialized. If it is specialized in a function, it gets
initialized once. If the class gets specialized globally,
it gets initialized twice.

The ARM seems to say nothing explicitly about it.
Is what I did legal? If so, according to the `law' of least surprises,
shouldn't the initializer get called once? And finally, of course,
is this a compiler bug? And was it fixed in cfront3.0.2?

Thanks!
(Please e-mail. I'll summarize and post when I get a definite answer)
:)
Mayan


