This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: _Alignas attribute and HOST_BITS_PER_INT
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- Cc: <gcc at gcc dot gnu dot org>, <rth at redhat dot com>
- Date: Wed, 27 Mar 2013 15:13:13 +0000
- Subject: Re: _Alignas attribute and HOST_BITS_PER_INT
- References: <20130327113610 dot GC7422 at atmel dot com>
On Wed, 27 Mar 2013, Senthil Kumar Selvaraj wrote:
> 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.
It expects either an error either about being too large, or about not
being a power of 2.
> Is it right to check against HOST_BITS_PER_INT, when the alignment
A check against HOST_BITS_PER_INT would be because of code inside GCC that
uses host "int" to store alignment values. Ideally there wouldn't be such
code - ideally any alignment up to and including the size of the whole
target address space could be used. (For example, alignments could always
be represented internally as a base-2 log.) But given the existence of
such code, such a check is needed.
However, a size that is not a power of 2 (such as this one, minus a power
of 2) should still be detected and get an error that this test accepts,
whether or not that size is also too large for host int. So look at why
you don't get the "requested alignment is not a power of 2" error for this
code with a negative alignment.
--
Joseph S. Myers
joseph@codesourcery.com