This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: PR3042
- To: Jason Merrill <jason_merrill at redhat dot com>, David Edelsohn <dje at watson dot ibm dot com>
- Subject: Re: PR3042
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Mon, 11 Jun 2001 11:15:15 -0700
- cc: "gdr at codesourcery dot com" <gdr at codesourcery dot com>, "Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr" <Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr>, "bkoz at nabi dot net" <bkoz at nabi dot net>, "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
--On Monday, June 11, 2001 06:20:51 PM +0100 Jason Merrill
<jason_merrill@redhat.com> wrote:
>>>>>> "David" == David Edelsohn <dje@watson.ibm.com> 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 mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com