This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH, PR 57748] Check for out of bounds access, Part 2


>> Did you just propose:
>>
>> --- stor-layout.c.orig 2013-10-22 10:46:49.233261818 +0200
>> +++ stor-layout.c 2013-10-24 14:54:00.425259062 +0200
>> @@ -471,27 +471,7 @@
>> static enum machine_mode
>> mode_for_array (tree elem_type, tree size)
>> {
>> - tree elem_size;
>> - unsigned HOST_WIDE_INT int_size, int_elem_size;
>> - bool limit_p;
>> -
>> - /* One-element arrays get the component type's mode. */
>> - elem_size = TYPE_SIZE (elem_type);
>> - if (simple_cst_equal (size, elem_size))
>> - return TYPE_MODE (elem_type);
>> -
>> - limit_p = true;
>> - if (host_integerp (size, 1) && host_integerp (elem_size, 1))
>> - {
>> - int_size = tree_low_cst (size, 1);
>> - int_elem_size = tree_low_cst (elem_size, 1);
>> - if (int_elem_size> 0
>> - && int_size % int_elem_size == 0
>> - && targetm.array_mode_supported_p (TYPE_MODE (elem_type),
>> - int_size / int_elem_size))
>> - limit_p = false;
>> - }
>> - return mode_for_size_tree (size, MODE_INT, limit_p);
>> + return BLKmode;
>> }
>>
>> ???
>
> Yes. Does it work?
>
> Richard.
>

I will give it a try.

I could also explicitly catch the case "struct { a[x]; };"
in compute_record_mode. That might work too.
But one way or the other that fix will be ugly.

Note:
struct Y { char c[1]; char c2; };

is "invalid" even if the expander would not fail,
because the code in tree-ssa-alias.c will not see the alias,
between c[2] and c2, that works only for the last array.
So that is no ICE but all generated code at -O1 and higher
will be wrong.

Bernd. 		 	   		  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]