[PATCH] fix struct alignment problem with empty base class

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Mon Jul 15 05:25:35 PDT 2013


Hi Eli,

> From: Eli Friedman <eli.friedman at gmail.com>
> On Fri, Jul 12, 2013 at 6:46 AM,  <Andrea_DiBiagio at sn.scee.net> wrote:
> > Hi,
> > attached is a patch to fix an alignment problem affecting classes 
derived
> > from a base with no fields but with strong alignment constraints.
> >
> > Let A be a strongly aligned struct/class with no fields.
> > Let B be a derived class with A as its direct base class.
> >
> > When performing the layout of B, A is correctly placed at offset 0 of 
B.
> > However, the alignment of B is wrongly left unchanged.
> >
> > <snip>
> >
> > This patch fixes the problem with the alignment and adds a test case 
to
> > verify that the alignment info is correctly updated.
> > One thing to note is that this change may have an effect on binary
> > compatibility between obj/libs built with and without this change (but
> > only in the - hopefully rare - case described above).
> 
> Index: test/CodeGenCXX/alignof.cpp
> ===================================================================
> --- test/CodeGenCXX/alignof.cpp (revision 0)
> +++ test/CodeGenCXX/alignof.cpp (revision 0)
> 
> Please move the test into SemaCXX, and use static_assert to verify the
> alignment instead of checking the IR.

I moved the test from CodeGenCXX to SemaCXX.
I renamed the test file into "alignment-of-derived-class.cpp" because I 
noticed that there was already a test called alignof.cpp in SemaCXX  which 
however tested something completely different.

> 
> +    // Remember max struct/class alignment.
> 
> This comment is useless.

I removed the comment above from the patch.

> 
> Otherwise, looks fine.
> 

Thanks!
In case, if this new version of the patch is ok, could you please commit 
it for me?

Thanks in advance,
Andrea Di Biagio
SN Systems - Sony Computer Entertainment Group.



**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify postmaster at scee.net
This footnote also confirms that this email message has been checked for 
all known viruses.
Sony Computer Entertainment Europe Limited
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United 
Kingdom
Registered in England: 3277793
**********************************************************************

P Please consider the environment before printing this e-mail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-alignof.diff
Type: application/octet-stream
Size: 2410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130715/2c6755e8/attachment.obj>


More information about the cfe-commits mailing list