This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: V3 static data in classes vs AIX
- To: David Edelsohn <dje at watson dot ibm dot com>
- Subject: Re: V3 static data in classes vs AIX
- From: Gabriel Dos Reis <gdr at codesourcery dot com>
- Date: 04 Jun 2001 22:30:05 +0200
- Cc: Mark Mitchell <mark at codesourcery dot com>, gdr at codesourcery dot com, bkoz at redhat dot com, libstdc++ at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <200106042013.QAA31064@makai.watson.ibm.com>
David Edelsohn <dje@watson.ibm.com> writes:
| IBM xlC 3.6.6.0 actually produces a common symbol as well (for
| class T instead of typename T). Your latest example does have a
| definition, not a reference:
|
| template <typename T> int S<T>::i;
|
| This latest commentary really doesn't make sense to me. Why is
| the compiler wrong and the library header right?
I don't fully understand all your message but I will try to answer
this and don't hesitate to correct if I misunderstand the issue.
With Mark's example
template <typename T>
struct S {
static int i; // this is -not- a definition.
};
template <typename T>
int S<T>::i; // this is a template definition
// and need not be instantiated.
int j = S<double>::i; // We need to "instantiate"
// S<double>::i from the template
// definition.
| Why are the multiple definitions correct? Yes, you can fake out
| the compiler, but why is it correct for the compiler to *NOT* create
| storage for a definition? Why should these multiple storage definitions
| be merged?
For implicit instantiations, the compiler is mandated to take
appropriate steps to merge possible multiple definitions.
| Do weak symbols specifically allow this type of use? Or is this
| specific to late binding? I still do not understand the differences
| between the semantics of COMMON and WEAK very well.
I would like to be educated on this issue as well :-)
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com