[Bug c/43798] attribute((aligned(x))) not honored for array element types?

2019-03-20 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43798

Richard Biener  changed:

   What|Removed |Added

 CC||xuzheliang at huawei dot com

--- Comment #5 from Richard Biener  ---
*** Bug 89769 has been marked as a duplicate of this bug. ***

[Bug c/43798] attribute((aligned(x))) not honored for array element types?

2010-04-19 Thread rguenth at gcc dot gnu dot org


--- Comment #1 from rguenth at gcc dot gnu dot org  2010-04-19 13:05 ---
Namely the bid_Kx192 decl looks like

 var_decl 0x75af8000 bid_Kx192
type array_type 0x75add7e0
type record_type 0x75add690 UINT192 type_0 BLK
size integer_cst 0x77ef70c8 constant 192
unit size integer_cst 0x77ef7078 constant 24
user align 128 symtab 0 alias set -1 canonical type 0x75add498
fields field_decl 0x77fb34c0 w context translation_unit_decl
0x75afe000 D.1631
pointer_to_this pointer_type 0x75add888
BLK
size integer_cst 0x77ef7258 constant 6144
unit size integer_cst 0x77fcfaa0 constant 768
user align 128 symtab 0 alias set -1 canonical type 0x75add9d8
domain integer_type 0x75add738
pointer_to_this pointer_type 0x75afc000
addressable used public static common BLK file t.c line 6 col 9 size
integer_cst 0x77ef7258 6144 unit size integer_cst 0x77fcfaa0 768
align 256 chain function_decl 0x75adcb00 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
the aligned-size.

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.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||jsm28 at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43798



[Bug c/43798] attribute((aligned(x))) not honored for array element types?

2010-04-19 Thread schwab at linux-m68k dot org


--- Comment #2 from schwab at linux-m68k dot org  2010-04-19 13:28 ---
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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43798



[Bug c/43798] attribute((aligned(x))) not honored for array element types?

2010-04-19 Thread jakub at gcc dot gnu dot org


--- 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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43798



[Bug c/43798] attribute((aligned(x))) not honored for array element types?

2010-04-19 Thread rguenther at suse dot de


--- Comment #4 from rguenther at suse dot de  2010-04-19 13:57 ---
Subject: Re:  attribute((aligned(x))) not honored for array
 element types?

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.

Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43798