This is the mail archive of the
mailing list for the libstdc++ project.
Re: V3 static data in classes vs AIX
- To: dje at watson dot ibm dot com
- Subject: Re: V3 static data in classes vs AIX
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Mon, 04 Jun 2001 13:57:23 -0700
- Cc: gdr at codesourcery dot com, bkoz at redhat dot com, libstdc++ at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <email@example.com><200106042036.QAA23396@makai.watson.ibm.com>
>>>>> "David" == David Edelsohn <firstname.lastname@example.org> writes:
David> Why is it correct for the header to produce multiple
What do you mean "produce multiple definitions"? In C++, header files
*must* contain definitions of template static data members so that
you can instantiate them with different types in different places.
That's specifically supported by the language.
I think you've got a C perspective here, and you think this is like
int i = 7;
in a header file. It's not.
I'll go one step further: there is *no way* to produce a broken C++
header that results in multiple definitions of a static data member in
a template unless you put an explicit instantiation in the header
file. The compilation system *must* allow the definition in the
header, no matter how many times the header is included and how many
times the template is implicitly instantiated.
In sum, barring extreme insanity, the V3 headers cannot be responsible
for erroneously creating multiple definitions of these template static
Non-template static data members would be a different situation
David> Just because it works, does not mean that it is
I'm not sure what you mean.
The goal of the compiler is to transform C++ source into object code
that behaves the way ANSI/ISO C++ says it should. That is really
the only measure of correctness.
The compiler uses certain properties of weak symbols on ELF systems to
accomplish the translation. I have no knowledge that it is incorrect,
in this respect, when presented with an ELF system.
Mark Mitchell email@example.com
CodeSourcery, LLC http://www.codesourcery.com