User account creation filtered due to spam.
in libbid we have
unsigned long long w;
thus we request 16-byte alignment for UINT192 (whose elements add
up to a size of 24). Now the array ends up with elements of size 24
and thus the elements are _not_ aligned to a 16-byte boundary, still
the element type is not adjusted to reflect that leading to inconsistencies
when one for example tries to set operand 3 of an ARRAY_REF
(which is specified in units of the alignment of the element).
This causes PR43783.
This is also at least a documentation bug as I can't find anything
that documents the above behavior.
Namely the bid_Kx192 decl looks like
<var_decl 0x7ffff5af8000 bid_Kx192
type <array_type 0x7ffff5add7e0
type <record_type 0x7ffff5add690 UINT192 type_0 BLK
size <integer_cst 0x7ffff7ef70c8 constant 192>
unit size <integer_cst 0x7ffff7ef7078 constant 24>
user align 128 symtab 0 alias set -1 canonical type 0x7ffff5add498 fields <field_decl 0x7ffff7fb34c0 w> context <translation_unit_decl 0x7ffff5afe000 D.1631>
pointer_to_this <pointer_type 0x7ffff5add888>>
size <integer_cst 0x7ffff7ef7258 constant 6144>
unit size <integer_cst 0x7ffff7fcfaa0 constant 768>
user align 128 symtab 0 alias set -1 canonical type 0x7ffff5add9d8
domain <integer_type 0x7ffff5add738>
pointer_to_this <pointer_type 0x7ffff5afc000>>
addressable used public static common BLK file t.c line 6 col 9 size <integer_cst 0x7ffff7ef7258 6144> unit size <integer_cst 0x7ffff7fcfaa0 768>
align 256 chain <function_decl 0x7ffff5adcb00 main>>
where the TYPE_ALIGN of the element type only applies to the first
array element. If you look at expr.c:array_ref_element_size then you
can see that there doesn't exist a valid TREE_OPERAND (array-ref, 3)
for indexing the above array as its TYPE_ALIGN_UNIT is bigger than
IMHO the C frontend ought to generate a variant type for the element
type that has its alignment adjusted (or it shall follow the users
request and add padding between the elements?). The current situation
is unfortunate for the middle-end.
An array cannot have internal padding, so the padding needs to be added to the element type.
The attempt to define such an array should probably be rejected.
At least with pointers alignment greater than size of the pointed to type (or not divisible by it) is often used to say that the start of the array is aligned some way.
Subject: Re: attribute((aligned(x))) not honored for array
On Mon, 19 Apr 2010, jakub at gcc dot gnu dot org wrote:
> ------- Comment #3 from jakub at gcc dot gnu dot org 2010-04-19 13:44 -------
> At least with pointers alignment greater than size of the pointed to type (or
> not divisible by it) is often used to say that the start of the array is
> aligned some way.
Yes, we correctly copy the (over-)alignment of the element type to
the array type. But the element type alignment then stays "wrong".