public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "arthur.j.odwyer at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108759] "mandatory copy elision" not implemented during constant evaluation redux
Date: Thu, 27 Apr 2023 17:39:58 +0000	[thread overview]
Message-ID: <bug-108759-4-vAUscHM35g@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108759-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108759

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot com

--- Comment #2 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
I believe what I'm going to say is simply a duplicate of Davis's report, but
just in case it's different, I'll add mine here. This is a slightly modified
version of the example from [class.copy.elision], merely modified so that g()
returns a C++17 prvalue instead of relying on NRVO/copy-elision.
Original example: https://eel.is/c++draft/class.copy.elision#2

Modified example:

// https://godbolt.org/z/n43jPs1Kj
struct A {
  void *p;
  constexpr A(): p(this) {}
};
constexpr A g() {
  return A();
}
constexpr A b = g();    // well-formed, b.p points to b
static_assert(b.p == &b);

MSVC and Clang accept. GCC incorrectly rejects:

<source>:11:19: error: 'A{((void*)(&<anonymous>))}' is not a constant
expression
   11 | constexpr A b = g();    // well-formed, b.p points to b
      |                   ^
<source>:12:19: error: non-constant condition for static assertion
   12 | static_assert(b.p == &b);
      |               ~~~~^~~~~

      parent reply	other threads:[~2023-04-27 17:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11  5:49 [Bug c++/108759] New: " herring at lanl dot gov
2023-02-13 17:20 ` [Bug c++/108759] " mpolacek at gcc dot gnu.org
2023-04-27 17:39 ` arthur.j.odwyer at gmail dot com [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=bug-108759-4-vAUscHM35g@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).