public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/108759] New: "mandatory copy elision" not implemented during constant evaluation redux @ 2023-02-11 5:49 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 0 siblings, 2 replies; 3+ messages in thread From: herring at lanl dot gov @ 2023-02-11 5:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108759 Bug ID: 108759 Summary: "mandatory copy elision" not implemented during constant evaluation redux Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: herring at lanl dot gov Target Milestone: --- Extending the test case in (the invalid) #94537 to have a user-provided destructor does not cause the "mandatory copy elision" to take place even though the implementation is no longer permitted to introduce a temporary: struct A; extern const A a; struct A { bool special=this==&a; constexpr ~A() {} }; constexpr A get() {return {};} // or "return A();" constexpr A a=get(); static_assert(a.special); ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/108759] "mandatory copy elision" not implemented during constant evaluation redux 2023-02-11 5:49 [Bug c++/108759] New: "mandatory copy elision" not implemented during constant evaluation redux herring at lanl dot gov @ 2023-02-13 17:20 ` mpolacek at gcc dot gnu.org 2023-04-27 17:39 ` arthur.j.odwyer at gmail dot com 1 sibling, 0 replies; 3+ messages in thread From: mpolacek at gcc dot gnu.org @ 2023-02-13 17:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108759 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-02-13 Status|UNCONFIRMED |NEW CC| |mpolacek at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Confirmed, we haven't elided the TARGET_EXPR: *<retval> = TARGET_EXPR <D.2533, {.special=(const struct A *) &<PLACEHOLDER_EXPR struct A> == &a}> ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/108759] "mandatory copy elision" not implemented during constant evaluation redux 2023-02-11 5:49 [Bug c++/108759] New: "mandatory copy elision" not implemented during constant evaluation redux 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 1 sibling, 0 replies; 3+ messages in thread From: arthur.j.odwyer at gmail dot com @ 2023-04-27 17:39 UTC (permalink / raw) To: gcc-bugs 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); | ~~~~^~~~~ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-27 17:39 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-02-11 5:49 [Bug c++/108759] New: "mandatory copy elision" not implemented during constant evaluation redux 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 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).