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: 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 11:11:52 -0700
- Cc: gdr at codesourcery dot com, bkoz at redhat dot com, libstdc++ at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <gdr@codesourcery.com><200106041756.NAA29764@makai.watson.ibm.com>
>>>>> "David" == David Edelsohn <dje@watson.ibm.com> writes:
David> Something is wrong with the V3 headers (or with the
David> G++ compiler) that including the headers generates
I suspect the compiler -- although there is also a workaround in the
headers, if I cam correct.
This is the same kind of thing we've had to work through multiple
times for AIX.
I suspect that what is triggering the problem is this code in
cp/decl2.c:comdat_linkage, which is supposed to try to approximate
COMDAT on systems that don't have it. In particular:
if (DECL_INITIAL (decl) == 0
|| DECL_INITIAL (decl) == error_mark_node)
DECL_COMMON (decl) = 1;
else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
{
DECL_COMMON (decl) = 1;
DECL_INITIAL (decl) = error_mark_node;
}
It looks like given, for example:
template <typename T>
struct S {
static int i;
};
template <typename T>
int S<T>::i;
int j = S<double>::i;
we will emit a COMMON definition for `S<double>::i'. (You could check
this to see if I'm guessing correctly.)
This code assumes that all COMMON definitions will eventuall be
merged, which is, from what you say, false on AIX.
I think it is a mistake for decl2.c to do this, and the block of code
above should just be removed. We already fail if the static data
member is initialized, and it would be very confusing to users to find
that adding an `= 0' to the above definition of `S::i' would fix the
problem.
So, I think there are probably two fixes:
- Remove the code in decl2.c, and then add explicit instantiations
for these static data members (if they are not already present
in V3). This makes the handling of all static data members
consistent.
- Add explicit initializers `= 0' in the V3 headers. This is
"safer" in that it doesn't involve changing the compiler, but
inferior in that you have to find *all* the static data members
in V3, and this adds a new rule that the V3 people will have to
remember forever more. It will be easier to debug and fix
things if we use the first alternative, since the failure mode
will be that things do not link due to missing explicit
instantiations.
If my hypothesis is correct, and removing the code fixes the problem,
then I would check that in, after the obligatory test-suite run.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com