This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: mutually-recursive types and an old puzzle
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Joe Buck <Joe dot Buck at synopsys dot COM>
- Cc: Zack Weinberg <zack at codesourcery dot com>, Chris Lattner <sabre at nondot dot org>, gcc at gcc dot gnu dot org
- Date: Thu, 01 Jul 2004 18:00:22 +0100
- Subject: Re: mutually-recursive types and an old puzzle
- Organization: Codesourcery LLC
- References: <Pine.LNX.4.44.0406291930070.1537-100000@nondot.org><32877.::ffff:128.194.146.36.1088556186.squirrel@webmail.nerim.net><20040629175356.A11677@synopsys.com><32929.::ffff:128.194.146.36.1088557164.squirrel@webmail.nerim.net><20040630122238.A23557@synopsys.com> <877jtox2ef.fsf@taltos.codesourcery.com> <32822.::ffff:24.250.169.187.1088649121.squirrel@webmail.nerim.net> <20040701091139.A20201@synopsys.com>
Joe Buck wrote:
ABIs that don't allow most STL iterators to be returned in a register
are, IMHO, broken. Unfortunately, it appears that we are stuck with
some broken ABIs.
Non-POD objects are those that can 'magically' be placed in
lists and stuff. Where by 'magical' I mean 'by code the compiler must call
but cannot see in the current translation unit'. Therefore the compiler
cannot go changing the address of such objects (or placing them in places
that have no address).
The actual C++ ABI makes the observation that it is the non-trivial copy
constructor and non-trivial destructor that have this magical property, and
hence only classes with either of those declared cannot be placed in
registers.
The problem with C++ is that if you declare *any* constructor, you have
to declare the copy constructor (if you want one), and if you declare it,
it's non-trivial. You need to be able to say 'make me the default copy
ctor'.
Of course, if the underlying C ABI cannot pass structs in registers, you're
out of luck anyway.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk