possible structure layout bug
Nathan Sidwell
nathan@codesourcery.com
Thu Jun 24 17:26:00 GMT 2004
Stephen Kennedy wrote:
> Is there any particular reason that the packing rules for have been
> changed from gcc-3.4 to gcc-3.5?
>
> I would have thought that this would break the ABI. Unless it is fixing
> existing breakage of course.
it is the latter case.
Base1 is non-pod, therefore its trailing padding can be overlaid by a
derived class.
Base2 is pod, therefore its trailing padding cannot be overlaid. The
gcc3.3 numbers show that it was being overlaid.
A program can legitimately use memcpy (x, y, sizeof (Base2))
to copy the Base2 part of a Derived2 object and not have that clobber
any other part of the Derived2 object.
Have you tested what 3.4 does?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
More information about the Gcc
mailing list