From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: Fix ICE in check_local_shadow with enum [PR95560]
Date: Mon, 15 Jun 2020 21:20:26 -0400 [thread overview]
Message-ID: <20200616012026.GJ53126@redhat.com> (raw)
In-Reply-To: <658d4558-d53b-fcad-9dc0-43e09e04e6a1@redhat.com>
On Thu, Jun 11, 2020 at 03:32:14PM -0400, Jason Merrill wrote:
> On 6/10/20 5:11 PM, Marek Polacek wrote:
> > Another indication that perhaps this warning is emitted too early. We
> > crash because same_type_p gets a null type: we have an enumerator
> > without a fixed underlying type and finish_enum_value_list hasn't yet
> > run. So check if the type is null before calling same_type_p.
>
> Hmm, I wonder why we use NULL_TREE for the type of uninitialized enumerators
> in a template; why not give them integer_type_node temporarily?
That breaks enum22.C:
template <class T>
struct A {
enum e_ : unsigned char { Z_, E_=sizeof(Z_) };
};
static_assert ( A<double>::E_ == 1, "E_ should be 1");
If we give 'Z_' a type, it's no longer instantiation-dependent, so sizeof(Z_)
immediately evaluates to 4. Whereas if it doesn't have a type, in the template
we create a SIZEOF_EXPR and only evaluate when instantiating (to 1).
This sounded like a problem big enough for me not to pursue this any further.
Do you want me to try anything else or is the original patch ok?
Marek
next prev parent reply other threads:[~2020-06-16 1:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 21:11 Marek Polacek
2020-06-11 19:32 ` Jason Merrill
2020-06-11 19:34 ` Jason Merrill
2020-06-11 19:34 ` Jason Merrill
2020-06-16 1:20 ` Marek Polacek [this message]
2020-06-16 16:06 ` Jason Merrill
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=20200616012026.GJ53126@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@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).