This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PR3042

--On Monday, June 11, 2001 06:20:51 PM +0100 Jason Merrill 
<> wrote:

>>>>>> "David" == David Edelsohn <> writes:
>> 	Is it valid C++ for a static class member to be instantiated with
>> a value in more than one module?
>>   template <class Z>
>>   int Y<Z>::m = 1;
> This is a definition of the template.  An explicit instantiation would
> look like
>   template <> int Y<int>::m;
> A template definition has logically weak linkage.  An explicit
> instantiation has logically strong linkage, though we use weak symbols for
> them anyway to avoid linker issues.
> So the answer to your question is no, but the answer for your example is
> yes.

David didn't actually specify implicit or explicit instantiation.

To be clear, the general rule is that you are allowed as many implicit 
instantiations as you want, and at most one explicit instantiation, spread 
out among the various translation units in your program.  (This is not
a fact about G++ implementation -- it is a fact about the language.)

I'm not sure if I'm answering the original question or not, but I thought
I'd throw that in.

Mark Mitchell         
CodeSourcery, LLC     

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]