Fix verify_type ICE with -fshort-enum

Richard Biener richard.guenther@gmail.com
Tue Jun 16 11:14:00 GMT 2015


On Fri, Jun 12, 2015 at 10:00 AM, Marek Polacek <polacek@redhat.com> wrote:
> On Thu, Jun 11, 2015 at 11:47:43PM +0200, Jan Hubicka wrote:
>> Hi,
>> gcc.c-torture/execute/930408-1.c currently ICE on -fshort-enum target(s) because
>> TYPE_PACKED is not consistently set among type variants.
>
> I guess that's because of the forward declaration in the test.  But I have
> no access to an ARM machine, so can't verify.
>
>> Bootstrapped/regtested ppc64le-linux, OK?
>> Honza
>>
>>       PR middle-end/66325
>>       * c-decl.c (start_enum): Set TYPE_PACKED consistently among type variants.
>> Index: c-decl.c
>> ===================================================================
>> --- c-decl.c  (revision 224250)
>> +++ c-decl.c  (working copy)
>> @@ -7946,7 +7946,8 @@
>>    the_enum->enum_overflow = 0;
>>
>>    if (flag_short_enums)
>> -    TYPE_PACKED (enumtype) = 1;
>> +    for (tree v = TYPE_MAIN_VARIANT (enumtype); v ;v = TYPE_NEXT_VARIANT (v))

Though I wonder why flag_short_enums was not true when building the
(main-)variant?
Looks like -fshort-enums is also 'Optimization', so the above is bogus for

enum foo {x = 1 };

void __attribute__((optimize(short-enums))) foo()
{
  const enum foo x = 1;
}

no?  The main variant is correctly _not_ packed but now you make it
packed as you reach foo ()?

Richard.

> Please fix the formatting here: no space before ;.
>
> Ok with that change.
>
>         Marek



More information about the Gcc-patches mailing list