public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100368] New: Missing guaranteed elision in constexpr evaluation
@ 2021-05-01  3:16 rs2740 at gmail dot com
  2021-05-03 15:17 ` [Bug c++/100368] " ppalka at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rs2740 at gmail dot com @ 2021-05-01  3:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100368
           Summary: Missing guaranteed elision in constexpr evaluation
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

struct S {
  S() = default;
  S(const S&) = delete;
};

struct array {
  S s[2];
};

struct PS {
  constexpr array operator*() const { return {}; }
};

struct W {
  constexpr W(const PS& p)   // 1
    : t(*p) {}
  array t;
};

W w(PS{});

This issues a spurious complaint on trunk and then ICEs:

source>: In constructor 'constexpr W::W(const PS&)':
<source>:17:14: error: use of deleted function 'array::array(array&&)'
   17 |     : t(*p) {}
      |              ^
<source>:7:8: note: 'array::array(array&&)' is implicitly deleted because the
default definition would be ill-formed:
    7 | struct array {
      |        ^~~~~
<source>:7:8: error: use of deleted function 'S::S(S&&)'
<source>:4:3: note: declared here
    4 |   S(S&&) = delete;
      |   ^
<source>:17:14: internal compiler error: tree check: expected target_expr, have
error_mark in bot_manip, at cp/tree.c:3095
   17 |     : t(*p) {}
      |              ^
0x1d002c9 internal_error(char const*, ...)
        ???:0
0x67b4e3 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0x13967e3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x9ad0ae break_out_target_exprs(tree_node*, bool)
        ???:0
0x72aa0a maybe_save_constexpr_fundef(tree_node*)
        ???:0
0x7b0711 finish_function(bool)
        ???:0
0x8e2c4d c_parse_file()
        ???:0
0xa63232 c_common_parse_file()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Removing the constexpr on the line marked #1 makes it compile. Both clang and
MSVC accept the original code.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100368] Missing guaranteed elision in constexpr evaluation
  2021-05-01  3:16 [Bug c++/100368] New: Missing guaranteed elision in constexpr evaluation rs2740 at gmail dot com
@ 2021-05-03 15:17 ` ppalka at gcc dot gnu.org
  2021-05-24 16:22 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-03 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2021-05-03

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, looks like this never worked.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100368] Missing guaranteed elision in constexpr evaluation
  2021-05-01  3:16 [Bug c++/100368] New: Missing guaranteed elision in constexpr evaluation rs2740 at gmail dot com
  2021-05-03 15:17 ` [Bug c++/100368] " ppalka at gcc dot gnu.org
@ 2021-05-24 16:22 ` ppalka at gcc dot gnu.org
  2021-05-26 13:08 ` cvs-commit at gcc dot gnu.org
  2021-10-01 18:28 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-24 16:22 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100368] Missing guaranteed elision in constexpr evaluation
  2021-05-01  3:16 [Bug c++/100368] New: Missing guaranteed elision in constexpr evaluation rs2740 at gmail dot com
  2021-05-03 15:17 ` [Bug c++/100368] " ppalka at gcc dot gnu.org
  2021-05-24 16:22 ` ppalka at gcc dot gnu.org
@ 2021-05-26 13:08 ` cvs-commit at gcc dot gnu.org
  2021-10-01 18:28 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-26 13:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:88834c7d05acf5ce4eaccda56fb04436595e2a52

commit r12-1068-g88834c7d05acf5ce4eaccda56fb04436595e2a52
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed May 26 08:37:30 2021 -0400

    c++: constexpr and copy elision within mem init [PR100368]

    In the testcase below, the member initializer b(f()) inside C's default
    constructor is encoded as a TARGET_EXPR wrapping the CALL_EXPR f() in
    C++17 mode.  During massaging of this constexpr constructor,
    build_target_expr_with_type called from bot_manip on this initializer
    tries to add an extra copy using B's implicitly deleted copy constructor
    rather than just preserving the copy elision.

    Since it's wrong to introduce an extra copy when initializing a
    temporary from a CALL_EXPR, this patch makes build_target_expr_with_type
    avoid calling force_rvalue in this case.  Additionally, bot_manip should
    be copying TARGET_EXPRs in a more oblivious manner, so this patch makes
    bot_manip use force_target_expr instead of build_target_expr_with_type.
    And since bot_manip is now no longer a caller, we can remove the void
    initializer handling in build_target_expr_with_type.

            PR c++/100368

    gcc/cp/ChangeLog:

            * tree.c (build_target_expr_with_type): Don't call force_rvalue
            on CALL_EXPR initializer.  Simplify now that bot_manip is no
            longer a caller.
            (bot_manip): Use force_target_expr instead of
            build_target_expr_with_type.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/elide6.C: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/100368] Missing guaranteed elision in constexpr evaluation
  2021-05-01  3:16 [Bug c++/100368] New: Missing guaranteed elision in constexpr evaluation rs2740 at gmail dot com
                   ` (2 preceding siblings ...)
  2021-05-26 13:08 ` cvs-commit at gcc dot gnu.org
@ 2021-10-01 18:28 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-01 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-01 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01  3:16 [Bug c++/100368] New: Missing guaranteed elision in constexpr evaluation rs2740 at gmail dot com
2021-05-03 15:17 ` [Bug c++/100368] " ppalka at gcc dot gnu.org
2021-05-24 16:22 ` ppalka at gcc dot gnu.org
2021-05-26 13:08 ` cvs-commit at gcc dot gnu.org
2021-10-01 18:28 ` ppalka at gcc dot gnu.org

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).