From: Richard Biener <richard.guenther@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Marek Polacek <polacek@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Fix verify_type ICE with -fshort-enum
Date: Wed, 17 Jun 2015 10:51:00 -0000 [thread overview]
Message-ID: <CAFiYyc3sKQsMz3oZp9NRbL4GtVZ=8pvi186h8pOMhyKKtSBxAQ@mail.gmail.com> (raw)
In-Reply-To: <20150616221007.GA24640@kam.mff.cuni.cz>
On Wed, Jun 17, 2015 at 12:10 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> >> 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?
>
> What I believe happens is that there is forward declaration of enum that leads
> to biuld incomplete enum type that has no packed flag set. Then we produce
> a type variant and after that we complete the main variant, but do not update
> the other variant.
>
> Actually looking into where the variant is updated, it happens in finish_enum
> that copies many flags, perhaps it would make more sense to copy TYPE_PACKED
> there?
Yes, it sounds like so.
>> 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 ()?
>
> Perhaps it is defined as Optimization but it does not bind to uses of types:
>
> enum foo {a,b,c};
> __attribute__((optimize("short-enums")))
> main()
> {
> const enum foo x;
> enum bar {a,b,c};
> printf ("%i %i\n",sizeof (x), sizeof(enum bar));
> }
>
> prints
> 4 1
>
> it depends when the main variant is finished. I wonder if there is any
> practical value on support Optimization attribute for this kind of ABI breaking
> options. It may be easier to simply drop the Optimization flag completely from
> -fshort-enums and friends.
>
> -fshort-double ICEs at initialization time at least since 4.8.x
> $ gcc t.c -fshort-double
> <built-in>: internal compiler error: in layout_type, at stor-layout.c:2220
> 0xafe41b layout_type(tree_node*)
> ../../gcc/stor-layout.c:2219
>
> so I suggest dropping that flag completely.
IIRC it "works" for -m32, but yes...
Yes also to _not_ make ABI changing flags 'Optimization'.
Richard.
> Honza
>>
>> Richard.
>>
>> > Please fix the formatting here: no space before ;.
>> >
>> > Ok with that change.
>> >
>> > Marek
prev parent reply other threads:[~2015-06-17 10:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 21:49 Jan Hubicka
2015-06-12 8:53 ` Marek Polacek
2015-06-16 11:14 ` Richard Biener
2015-06-16 22:16 ` Jan Hubicka
2015-06-17 10:51 ` Richard Biener [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFiYyc3sKQsMz3oZp9NRbL4GtVZ=8pvi186h8pOMhyKKtSBxAQ@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=polacek@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).