public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
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 noexcept with unevaluated operand [PR101087]
Date: Thu, 8 Jul 2021 09:35:02 -0400	[thread overview]
Message-ID: <YOb/BmPbSiNFiwNZ@redhat.com> (raw)
In-Reply-To: <1ca95175-4fe6-60d6-d6f1-e634ffdd271c@redhat.com>

On Thu, Jul 08, 2021 at 09:30:27AM -0400, Jason Merrill wrote:
> On 7/7/21 9:40 PM, Marek Polacek wrote:
> > It sounds plausible that this assert
> > 
> >    int f();
> >    static_assert(noexcept(sizeof(f())));
> > 
> > should pass: sizeof produces a std::size_t and its operand is not
> > evaluated, so it can't throw.  noexcept should only evaluate to
> > false for potentially evaluated operands.  Therefore I think that
> > check_noexcept_r shouldn't walk into operands of sizeof/decltype/
> > alignof/typeof.  Only checking cp_unevaluated_operand therein does
> > not work, because expr_noexcept_p can be called in an unevaluated
> > context, so I resorted to the following cp_evaluated hack.  Does
> > that seem acceptable?
> 
> I suppose, but why not check for SIZEOF_EXPR/ALIGNOF_EXPR/NOEXCEPT_EXPR
> directly?

I thought I would, but then it occurred to me that it might be better to
rely on cp_walk_subtrees which ++/--s cp_unevaluated_operand for those
codes.  I'd be happy to change the patch to check those codes directly;
maybe I'm overthinking things here.

--
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA


  reply	other threads:[~2021-07-08 13:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  1:40 Marek Polacek
2021-07-08 13:30 ` Jason Merrill
2021-07-08 13:35   ` Marek Polacek [this message]
2021-07-08 20:26     ` [PATCH v2] " Marek Polacek
2021-07-08 21:34       ` Jason Merrill
2021-07-08 21:37         ` Marek Polacek

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=YOb/BmPbSiNFiwNZ@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).