public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653
@ 2022-05-09  7:47 marxin at gcc dot gnu.org
  2022-05-09  7:47 ` [Bug c++/105529] " marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-09  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105529
           Summary: [13 Regression] cxx_eval_store_expression, at
                    cp/constexpr.cc:5928 since r13-160-g967cdbe6629653
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: jason at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-linux-gnu
            Target: arm-linux-eabi

The following crashes with the given cross compiler:

$ cat sstream-inst.ii
struct allocator {
  constexpr ~allocator() {}
};
struct Trans_NS___cxx11_basic_string {
  Trans_NS___cxx11_basic_string(int, int, allocator = allocator());
};
void to_string() { Trans_NS___cxx11_basic_string(0, '\0'); }

$ ./xg++ -B. sstream-inst.ii -c -std=gnu++20 -O
sstream-inst.ii: In function ‘void to_string()’:
sstream-inst.ii:7:60:   in ‘constexpr’ expansion of
‘<anonymous>.allocator::~allocator()’
sstream-inst.ii:7:60: internal compiler error: in cxx_eval_store_expression, at
cp/constexpr.cc:5928
    7 | void to_string() { Trans_NS___cxx11_basic_string(0, '\0'); }
      |                                                            ^
0xb8412a cxx_eval_store_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:5928
0xb87c46 cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:6848
0xb87d41 cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:6860
0xb8503f cxx_eval_statement_list
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:6178
0xb8a158 cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:7407
0xb87f45 cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:6906
0xb76e4c cxx_eval_call_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:2855
0xb87084 cxx_eval_constant_expression
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:6719
0xb8c200 cxx_eval_outermost_constant_expr
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:7824
0xb8d06e maybe_constant_value(tree_node*, tree_node*, bool)
        /home/marxin/Programming/gcc/gcc/cp/constexpr.cc:8102
0xbcff2b cp_fold
        /home/marxin/Programming/gcc/gcc/cp/cp-gimplify.cc:2880
0xbcddd2 cp_fold
        /home/marxin/Programming/gcc/gcc/cp/cp-gimplify.cc:2467
0xbc6c66 cp_fold_r
        /home/marxin/Programming/gcc/gcc/cp/cp-gimplify.cc:1011
0x1b91df5 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*> >*))
        /home/marxin/Programming/gcc/gcc/tree.cc:11199
0x1b9278f 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*> >*))
        /home/marxin/Programming/gcc/gcc/tree.cc:11334
0x1b9278f 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*> >*))
        /home/marxin/Programming/gcc/gcc/tree.cc:11334
0xbc73f9 cp_fold_function(tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/cp-gimplify.cc:1114
0xc42ff8 finish_function(bool)
        /home/marxin/Programming/gcc/gcc/cp/decl.cc:17967
0xda2a1f cp_parser_function_definition_after_declarator
        /home/marxin/Programming/gcc/gcc/cp/parser.cc:31331
0xda283b cp_parser_function_definition_from_specifiers_and_declarator
        /home/marxin/Programming/gcc/gcc/cp/parser.cc:31244
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
@ 2022-05-09  7:47 ` marxin at gcc dot gnu.org
  2022-05-09  8:15 ` [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-09  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-05-09
             Status|UNCONFIRMED                 |NEW

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
  2022-05-09  7:47 ` [Bug c++/105529] " marxin at gcc dot gnu.org
@ 2022-05-09  8:15 ` rguenth at gcc dot gnu.org
  2022-05-09  8:48 ` dcb314 at hotmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-09  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
            Version|12.0                        |13.0

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
  2022-05-09  7:47 ` [Bug c++/105529] " marxin at gcc dot gnu.org
  2022-05-09  8:15 ` [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this " rguenth at gcc dot gnu.org
@ 2022-05-09  8:48 ` dcb314 at hotmail dot com
  2022-05-09 16:31 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dcb314 at hotmail dot com @ 2022-05-09  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

David Binderman <dcb314 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcb314 at hotmail dot com

--- Comment #1 from David Binderman <dcb314 at hotmail dot com> ---
I see this also on a native Raspberry pi compiler.

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-05-09  8:48 ` dcb314 at hotmail dot com
@ 2022-05-09 16:31 ` mpolacek at gcc dot gnu.org
  2022-05-09 17:11 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-09 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
We're in cxx_eval_store_expression, evaluating <retval> = this, this is while
evaluating a CALL_EXPR allocator::~allocator (&D.4529).  We're on ARM, so
cdtors return this.

init is evaluated to &D.4529 [allocator *], object is <retval> [void *].  Their
types aren't the same so we go to

  if (empty_base || !(same_type_ignoring_top_level_qualifiers_p
                      (TREE_TYPE (init), type)))
    {    
      /* For initialization of an empty base, the original target will be
       *(base*)this, evaluation of which resolves to the object
       argument, which has the derived type rather than the base type.  In
       this situation, just evaluate the initializer and return, since
       there's no actual data to store, and we didn't build a CONSTRUCTOR.  */
      empty_base = true;
      gcc_assert (is_empty_class (TREE_TYPE (init)));

and is_empty_class will always say false for a pointer type -> ICE.  I don't
think we should have gotten into this branch.

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-05-09 16:31 ` mpolacek at gcc dot gnu.org
@ 2022-05-09 17:11 ` mpolacek at gcc dot gnu.org
  2022-05-10  5:06 ` cvs-commit at gcc dot gnu.org
  2022-05-10  5:06 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-09 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Therefore, a potential fix would be:

--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -5916,8 +5916,9 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree
t,

   gcc_checking_assert (!*valp || (same_type_ignoring_top_level_qualifiers_p
                  (TREE_TYPE (*valp), type)));
-  if (empty_base || !(same_type_ignoring_top_level_qualifiers_p
-             (TREE_TYPE (init), type)))
+  if (empty_base || (CLASS_TYPE_P (TREE_TYPE (init))
+            && !(same_type_ignoring_top_level_qualifiers_p
+             (TREE_TYPE (init), type))))
     {
       /* For initialization of an empty base, the original target will be
        *(base*)this, evaluation of which resolves to the object


This code expects code like

  D.2181 = {}

where the type of the LHS is the derived type and the type of the RHS is the
base type.

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-05-09 17:11 ` mpolacek at gcc dot gnu.org
@ 2022-05-10  5:06 ` cvs-commit at gcc dot gnu.org
  2022-05-10  5:06 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-10  5:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:bb2921ab84dba014f24be06663636c7fb1361474

commit r13-221-gbb2921ab84dba014f24be06663636c7fb1361474
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 9 16:03:35 2022 -0400

    c++: fix arm-eabi crash building libstdc++ [PR105529]

    My recent change to cxx_eval_store_expression asserts that the target and
    value can only end up having different types in the case of an empty base;
    this was crashing arm-eabi compilers because in that ABI [cd]tors
    return *this, and weren't converting it to void* first.

    This also shares the 'return this' code between the three places it occurs.

    Thanks to Marek for the tests.

            PR c++/105529

    gcc/cp/ChangeLog:

            * decl.cc (maybe_return_this): Replace...
            (finish_constructor_body, finish_destructor_body): ...these.
            (finish_function_body): Call it.
            * optimize.cc (build_delete_destructor_body): Call it.
            * cp-tree.h (maybe_return_this): Declare.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/constexpr-dtor13.C: New test.
            * g++.dg/cpp2a/constexpr-dtor14.C: New test.

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

* [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this since r13-160-g967cdbe6629653
  2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-05-10  5:06 ` cvs-commit at gcc dot gnu.org
@ 2022-05-10  5:06 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-10  5:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-05-10  5:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09  7:47 [Bug c++/105529] New: [13 Regression] cxx_eval_store_expression, at cp/constexpr.cc:5928 since r13-160-g967cdbe6629653 marxin at gcc dot gnu.org
2022-05-09  7:47 ` [Bug c++/105529] " marxin at gcc dot gnu.org
2022-05-09  8:15 ` [Bug c++/105529] [13 Regression] cxx_eval_store_expression on arm because of ctor returning this " rguenth at gcc dot gnu.org
2022-05-09  8:48 ` dcb314 at hotmail dot com
2022-05-09 16:31 ` mpolacek at gcc dot gnu.org
2022-05-09 17:11 ` mpolacek at gcc dot gnu.org
2022-05-10  5:06 ` cvs-commit at gcc dot gnu.org
2022-05-10  5:06 ` jason 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).