From: Marek Polacek <polacek@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: Re: [PATCH] c++: ICE with noexcept and local specialization [PR114114]
Date: Thu, 21 Mar 2024 17:04:19 -0400 [thread overview]
Message-ID: <Zfyg09xYMi4rj6vK@redhat.com> (raw)
In-Reply-To: <abc8b9bf-7368-5568-92db-93416757c7c7@idea>
On Fri, Mar 15, 2024 at 12:12:49PM -0400, Patrick Palka wrote:
> On Fri, 15 Mar 2024, Marek Polacek wrote:
>
> > On Fri, Mar 15, 2024 at 10:35:07AM -0400, Patrick Palka wrote:
> > > On Tue, 5 Mar 2024, Marek Polacek wrote:
> > >
> > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> > > >
> > > > -- >8 --
> > > > Here we ICE because we call register_local_specialization while
> > > > local_specializations is null, so
> > > >
> > > > local_specializations->put ();
> > > >
> > > > crashes on null this. It's null since maybe_instantiate_noexcept calls
> > > > push_to_top_level which creates a new scope. Normally, I would have
> > > > guessed that we need a new local_specialization_stack. But here we're
> > > > dealing with an operand of a noexcept, which is an unevaluated operand,
> > > > and those aren't registered in the hash map. maybe_instantiate_noexcept
> > > > wasn't signalling that it's substituting an unevaluated operand though.
> > >
> > > It thought it was noexcept-exprs rather than noexcept-specs that are
> > > unevaluated contexts?
> >
> > Yes, sigh. It would have to be noexcept(noexcept(x)). I was looking at
> > cp_parser_unary_expression/RID_NOEXCEPT but that's a noexcept-expr. So
> > what can we do here, set a new local_specialization_stack? That wasn't
> > that straightforward when I tried. Or maybe just
>
> Maybe we can avoid doing push_to_top_level (which clears
> local_specializations) from maybe_instantiate_noexcept if
> current_function_decl == fn?
Thanks, I agree that not doing push_to_top_level in the first place
is a better fix. I just sent a patch that does that.
> Relatedly I wonder if we can avoid calling regenerate_decl_from_template
> for local class member functions since they can't be redeclared?
Good point. I've tried the below, but that breaks a lot of contracts tests.
I have not pursued it further than that.
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index a7ba8b5af92..5352453a5d3 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -26623,6 +26623,12 @@ regenerate_decl_from_template (tree decl, tree tmpl, tree args)
if (DECL_UNIQUE_FRIEND_P (decl))
goto done;
+ /* [class.mem.general]/5 says that a member shall not be declared twice
+ in the member-specification (unless it's a nested class or member class
+ template or an enumeration). */
+ if (DECL_CLASS_SCOPE_P (decl))
+ goto done;
+
/* Use the source location of the definition. */
DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (tmpl);
Marek
prev parent reply other threads:[~2024-03-21 21:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 20:56 Marek Polacek
2024-03-05 23:20 ` Jason Merrill
2024-03-15 14:35 ` Patrick Palka
2024-03-15 15:23 ` Marek Polacek
2024-03-15 16:12 ` Patrick Palka
2024-03-21 21:04 ` Marek Polacek [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=Zfyg09xYMi4rj6vK@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=ppalka@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).