public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ville Voutilainen <ville.voutilainen@gmail.com>
To: Stephan Bergmann <sbergman@redhat.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
	"libstdc++" <libstdc++@gcc.gnu.org>,
	 gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [committed] libstdc++: Allow Lemire's algorithm to be used in more cases
Date: Wed, 4 Nov 2020 10:52:55 +0200	[thread overview]
Message-ID: <CAFk2RUaYyjjGekZ0m75HAvoK5Jb2ndbyVW3QzAkGQ++F=sbRoA@mail.gmail.com> (raw)
In-Reply-To: <51c2aa0b-7a1c-8174-6492-fdee634ef8e0@redhat.com>

On Wed, 4 Nov 2020 at 10:46, Stephan Bergmann via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
> To me it looks like it boils down to disagreement between g++ and
> clang++ over
>
> > struct S { static constexpr int f() { return 0; } };
> > void f(S & s) { static_assert(s.f(), ""); }
>
> where I think Clang might be right in rejecting it based on [expr.const]
> "An expression e is a core constant expression unless [...] an
> id-expression that refers to a variable or data member of reference type
> unless the reference has a preceding initialization [...]"

There's more to it than that. It's a disagreement over [expr.ref]/1.
For a static
member call, gcc just plain doesn't evaluate the s in s.f(). But [expr.ref]/1
says it's evaluated, and since it's not a constant expression, clang rejects
it, and gcc accepts it. That's why your fix works; it removes the use
of the otherwise-mostly-ignored
object expression for a call to a static member function.

So, I think gcc is accepting-invalid here, and we should just apply
the fix you suggested.

  reply	other threads:[~2020-11-04  8:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 14:59 Jonathan Wakely
2020-11-03 21:28 ` Stephan Bergmann
2020-11-03 22:25   ` Jonathan Wakely
2020-11-04  8:45     ` Stephan Bergmann
2020-11-04  8:52       ` Ville Voutilainen [this message]
2020-11-04 10:15       ` Jonathan Wakely
2020-11-04 10:38         ` Jonathan Wakely

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='CAFk2RUaYyjjGekZ0m75HAvoK5Jb2ndbyVW3QzAkGQ++F=sbRoA@mail.gmail.com' \
    --to=ville.voutilainen@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=sbergman@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).