This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: AIX, Solaris 2.8 excess errors fails
- From: Mark Mitchell <mark at codesourcery dot com>
- To: David Edelsohn <dje at watson dot ibm dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Benjamin Kosnik <bkoz at redhat dot com>, "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 20 Feb 2002 19:29:55 -0800
- Subject: Re: AIX, Solaris 2.8 excess errors fails
> + // Explicitly instantiate for systems with no COMDAT or weak support.
> + template
> + std::basic_string<unsigned short>::size_type
> + std::basic_string<unsigned short>::_Rep::_S_max_size;
> +
> + template
> + unsigned short
> + std::basic_string<unsigned short>::_Rep::_S_terminal;
I think maybe you have a point, but you're not making it in a way
that anyone understands. :-) I'll try to make it for you and see if
it's what you mean.
The point is that instantiations of basic_string<unsigned short>
are very rare -- as in there are pretty much no real programs that
do this. However, the library is supposed to support this, so they
wrote a test to do it.
The only plausible implementation of certain standard-required behavior
is to have the static data members you see above. So, somehow, these
things have to get instantiated.
Now, on platforms with weak symbols, G++ does the right thing, without
any explicit instantiation. On platforms without weak symbols, you
need the explicit instantiation due to limitations in the compilation
system. So, you can put the explicit instantiation in the library,
or you can put it in your code, i.e., the test. It doesn't belong
in the library -- nobody really wants that instantiation -- so it has
to go in the test.
However -- and this is where I'm trying to read your mind -- if you
always put the explicit instantiation in the test, so as to accomodate
systems without weak symbols, you make the test less valuable in that
now you are not testing the library in the way that users would
normally use it on systems *with* weak symbols. In theory, things
could now be broken on systems with weak symbols, but you wouldn't
notice.
On the one hand, that's probably not a very real problem. We've
got lots of implicit instantiation tests.
On the other hand, it's a valid point. That would lead me to say
that what we should do in the tests is:
#if !__GXX_WEAK
// Explicitly instantiate; the compilation system is incapable
// of doing it for us.
template ....
#endif /* !__GXX_WEAK */
If that's what you're suggesting, I agree; that would test the library
in the way it's most likely to be used on both kinds of systems.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com