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: V3 static data in classes vs AIX

>>>>> "David" == David Edelsohn <> writes:

    David> 	Why is it correct for the header to produce multiple
    David> definitions? 

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
data members.

Non-template static data members would be a different situation

    David> 	Just because it works, does not mean that it is
    David> correct.  

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         
CodeSourcery, LLC     

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