V3 static data in classes vs AIX
Gabriel Dos Reis
gdr@codesourcery.com
Mon Jun 4 13:30:00 GMT 2001
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
More information about the Libstdc++
mailing list