This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
_Alignas attribute and HOST_BITS_PER_INT
- From: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- To: <gcc at gcc dot gnu dot org>
- Cc: <joseph at codesourcery dot com>, <rth at redhat dot com>
- Date: Wed, 27 Mar 2013 17:06:13 +0530
- Subject: _Alignas attribute and HOST_BITS_PER_INT
Hi,
I was looking at why gcc.dg/c1x-align-3.c (test for errors, line 15) is
failing for the AVR target, and I found that the test expects _Alignas
with -__INT_MAX__ - 1 to fail with a "too large" error.
I looked at the code responsible for generating the error (c-common.c,
check_user_alignment) and found that it checks if the number of
bits in the user provided alignment is more than HOST_BITS_PER_INT -
BITS_PER_UNIT_LOG. For AVR, integer size is 16 bits, and therefore
__INT_MAX__ is 2^15 - 1. HOST_BITS_PER_INT, however, is 32 bits, and
hence the error is not triggered.
Is it right to check against HOST_BITS_PER_INT, when the alignment
attribute only applies to the target? If the check is indeed correct,
should the test be modified to handle targets whose __INT__MAX__ is less
than 2^HOST_BITS_PER_INT - 1 ?
Regards
Senthil