[Patch] Fix PR44328 - switch/case optimization produces an invalid lookup table index

Richard Guenther richard.guenther@gmail.com
Wed Aug 18 09:31:00 GMT 2010


On Tue, Aug 17, 2010 at 6:06 PM, Ian Bolton <Ian.Bolton@arm.com> wrote:
> H.J.Lu writes:
>> > H.J.Lu writes:
>> >> I am open to suggestions as to where it should go, and what
>> >> > options to give it.
>> >>
>> >> gcc.dg?
>> >>
>> >> > For trunk, I need "-fstrict-enums -O2 -Wextra" to cause the
>> >> > circumstances that exposed the bug, and check that there are
>> >> > no warnings.  For 4.5 branch, -fstrict-enums does not exist,
>> >> > so I guess I only want "-O2 -Wextra".
>> >> >
>> >>
>> >> Only add -fstrict-enums to test in trunk.
>> >>
>> >
>> > Thanks for your help.  As the test is a C++ one, I have added it
>> > to testsuite/g++.dg, and updated the patch accordingly.
>> >
>> > Note that this is intended for 4.5 branch, as I have not
>> > supplied -fstrict-enums in the test.
>> >
>> > Best regards,
>> > Ian
>> >
>> >
>> >
>> > 2010-08-16  Ian Bolton  <ian.bolton@arm.com>
>> >
>> >        * tree-switch-conversion.c (gen_inbound_check): Ensure that
>> the
>> >        type for the conditional has wide enough range.
>> >
>> >        * testsuite/g++.dg/pr44328.C: New test.
>> >
>>
>> You should submit the patch for trunk first and backport to 4.5 branch
>> after it was checked into trunk.
>
> I have ran into trouble creating a test-case for trunk, because the
> second invocation of tree_forwprop hides the issue.  I have hacked the
> code to only allow the first pass of tree_forwprop and it can then be
> seen that vrp1 erroneously turns <= 2 into != 3 due to having the wrong
> type for the switch index.  (My fix prevents this from happening.)
>
> What do you suggest I do with regards the patch for trunk?  Should I
> include no test, or should I include the test I created for 4.5 branch,
> even though it won't actually catch the trunk issue?

Do the latter - use the 4.5 testcase.

Richard.

> Best regards,
> Ian
>
>
>



More information about the Gcc-patches mailing list