On 10/30/18 3:40 PM, Martin Sebor wrote:
> Bug 87795 - Excessive alignment permitted for functions and labels
> points out that the handler for attribute aligned makes it possible
> for unsupported alignments to be accepted by the front end only to
> be either rejected later on by some targets for variables, or to
> cause an ICE for overaligned functions.
> 
> The reason for the problems is that the attribute handler considers
> any power of two alignment valid whose log2  is less than
> HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT, but later parts of GCC
> assume values of at most MAX_OFILE_ALIGNMENT / BITS_PER_UNIT.
> The internals manual documents MAX_OFILE_ALIGNMENT as:
> 
>   Biggest alignment supported by the object file format of this
>   machine. Use this macro to limit the alignment which can be
>   specified using the __attribute__ ((aligned (n))) construct.
> 
> So it seems that the attribute handler should be using this macro
> instead.  I also took the liberty to add more detail to the error
> messages.  Attached is a patch that makes this change.  Tested on
> x86_64-linux, plus using cross-compilers for arm, hppa64, pdp11,
> and powerpc64.
> 
> Martin
> 
> gcc-87795.diff
> 
> PR c/87795 - Excessive alignment permitted for functions and labels
> 
> gcc/c-family/ChangeLog:
> 
>       PR c/87795
>       * c-common.c (check_user_alignment): Use MAX_OFILE_ALIGNMENT.
> 
> gcc/testsuite/ChangeLog:
> 
>       PR c/87795
>       * gcc.dg/attr-aligned.c: New test.
OK
jeff

Reply via email to