This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR 57748] Check for out of bounds access, Part 2
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Martin Jambor <mjambor at suse dot cz>
- Date: Thu, 24 Oct 2013 15:09:09 +0200
- Subject: Re: [PATCH, PR 57748] Check for out of bounds access, Part 2
- Authentication-results: sourceware.org; auth=none
- References: <20130910193228 dot GE6732 at virgil dot suse> <20131023171106 dot GC22314 at virgil dot suse> <DUB122-W18EE8845FD49B5DF19B227E40C0 at phx dot gbl> <3910341 dot 1yrhooXIjO at polaris> <CAFiYyc0+6E5jQijgb+xVitqJZoDTy5EHNtHS2fPdVQx_BD1jUA at mail dot gmail dot com> <DUB122-W3250D65A780768771CDEB5E40C0 at phx dot gbl>
On Thu, Oct 24, 2013 at 2:55 PM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> On Thu, 24 Oct 2013 12:18:43, Richard Biener wrote:
>>
>> On Thu, Oct 24, 2013 at 10:48 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>>> I think that is common practice to write array[1]; at the end of the
>>>> structure, and use it as a flexible array. The compute_record_mode has no
>>>> way to decide if that is going to be a flexible array or not.
>>>>
>>>> Sorry Eric, but now I have no other choice than to go back to my previous
>>>> version of part 2:
>>>>
>>>> http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00222.html
>>>
>>> Why? Just set BLKmode in this case as well.
>>
>> Works for me if it works ABI-wise (which you say it should unless the
>> backend is buggy). Note that means mode_for_array should unconditionally
>> return BLKmode.
>
> 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.
>
>> Richard.
>>
>>> --
>>> Eric Botcazou
- References:
- Re: [PATCH, PR 57748] Check for out of bounds access, Part 2
- RE: [PATCH, PR 57748] Check for out of bounds access, Part 2
- Re: [PATCH, PR 57748] Check for out of bounds access, Part 2
- Re: [PATCH, PR 57748] Check for out of bounds access, Part 2
- RE: [PATCH, PR 57748] Check for out of bounds access, Part 2