public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
@ 2022-10-16 19:16 jwjagersma at gmail dot com
  2022-10-17 11:42 ` [Bug c++/107280] " marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jwjagersma at gmail dot com @ 2022-10-16 19:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107280
           Summary: ICE: tree check: expected constructor, have
                    view_convert_expr in cxx_eval_store_expression, at
                    cp/constexpr.cc:5928
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwjagersma at gmail dot com
  Target Milestone: ---

Created attachment 53710
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53710&action=edit
output from -freport-bug

Ran into this today, while trying to do some basic string manipulation:

    $ cat ~/ice.cpp
    struct string
    {
      char str[8] = "       ";
      const char* data() { return str; }
    };

    template<bool a, bool b>
    consteval string test()
    {
      string str { };
      char* p = str.str;

      auto append = [&p](const char* s)
      {
        while (*s != '\0') *p++ = *s++;
        ++p;
      };

      if (a) append("abc");
      if (b) append("xyz");
      return str;
    }

    auto f() { return test<true,true>(); }

    $ g++ -std=c++20 ~/ice.cpp
    /home/jw/ice.cpp: In function 'auto f()':
    /home/jw/ice.cpp:24:34:   in 'constexpr' expansion of 'test<true, true>()'
    /home/jw/ice.cpp:19:16:   in 'constexpr' expansion of 'append.test<true,
true>()::<lambda(const char*)>(((const char*)"abc"))'
    /home/jw/ice.cpp:24:34: internal compiler error: tree check: expected
constructor, have view_convert_expr in cxx_eval_store_expres
    sion, at cp/constexpr.cc:5928
       24 | auto f() { return test<true,true>(); }
          |                   ~~~~~~~~~~~~~~~^~
    ...

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

* [Bug c++/107280] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
@ 2022-10-17 11:42 ` marxin at gcc dot gnu.org
  2022-10-17 20:47 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-17 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-10-17
   Target Milestone|---                         |13.0
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, thanks for the test-case, reduced to:

$ cat pr107280.C
struct string {
  char str[8] = "";
};
template <int, int> consteval void test() {
  string str{};
  auto append = [&](char *s) { *str.str = *s; };
  append("");
}
auto f() { test<true, true>(); }

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

* [Bug c++/107280] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
  2022-10-17 11:42 ` [Bug c++/107280] " marxin at gcc dot gnu.org
@ 2022-10-17 20:47 ` mpolacek at gcc dot gnu.org
  2023-03-08 22:08 ` [Bug c++/107280] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-10-17 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r277733:

commit f968ef9b8df2bc2287e5e7e87299e5a2a44e8c94
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Nov 2 00:28:20 2019 +0100

    PR c++/88335 - Implement P1073R3: Immediate functions

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

* [Bug c++/107280] [10/11/12/13 Regression] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
  2022-10-17 11:42 ` [Bug c++/107280] " marxin at gcc dot gnu.org
  2022-10-17 20:47 ` mpolacek at gcc dot gnu.org
@ 2023-03-08 22:08 ` mpolacek at gcc dot gnu.org
  2023-03-08 22:40 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-08 22:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE: tree check: expected   |[10/11/12/13 Regression]
                   |constructor, have           |ICE: tree check: expected
                   |view_convert_expr in        |constructor, have
                   |cxx_eval_store_expression,  |view_convert_expr in
                   |at cp/constexpr.cc:5928     |cxx_eval_store_expression,
                   |                            |at cp/constexpr.cc:5928
   Target Milestone|13.0                        |10.5
           Priority|P3                          |P2

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This isn't about consteval.  Adjusted C++17 test:

// PR c++/107280

struct string {
  char str[8] = "";
};
template <int, int> constexpr void
test ()
{
  string str{};
  auto append = [&](const char *s) { *str.str = *s; };
  append("");
}

static_assert ((test<true, true>(), true), "");

Started with r10-3661-g8e007055dd1374, making this a regression.

commit 8e007055dd1374ca4c44406a4ead172be0dfa3a8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Oct 5 09:38:21 2019 +0200

    PR c++/91369 - Implement P0784R7: constexpr new

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

* [Bug c++/107280] [10/11/12/13 Regression] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
                   ` (2 preceding siblings ...)
  2023-03-08 22:08 ` [Bug c++/107280] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
@ 2023-03-08 22:40 ` mpolacek at gcc dot gnu.org
  2023-03-08 22:46 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-08 22:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
We crash in cxx_eval_store_expression.  *valp for 'str', the VAR_DECL, used to
be {.str=""} so in the !refs->is_empty () loop we'd go to the if (TREE_CODE
(*valp) == STRING_CST) branch when processing the .str initializer.  But now
*valp is {.str=VCE<char[8]>("")} so we crash on
no_zero_init = CONSTRUCTOR_NO_CLEARING (*valp);

So far it seems to me that we just need to strip the location wrapper.

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

* [Bug c++/107280] [10/11/12/13 Regression] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
                   ` (3 preceding siblings ...)
  2023-03-08 22:40 ` mpolacek at gcc dot gnu.org
@ 2023-03-08 22:46 ` mpolacek at gcc dot gnu.org
  2023-03-15 18:28 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-08 22:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

* [Bug c++/107280] [10/11/12/13 Regression] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
                   ` (4 preceding siblings ...)
  2023-03-08 22:46 ` mpolacek at gcc dot gnu.org
@ 2023-03-15 18:28 ` cvs-commit at gcc dot gnu.org
  2023-03-15 18:29 ` cvs-commit at gcc dot gnu.org
  2023-03-15 18:30 ` [Bug c++/107280] [10/11 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-15 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r13-6697-gbe20dcc359bcc4677c5b9ce011d3cd7b4ce94a64
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Mar 10 10:14:20 2023 -0500

    c++: ICE with constexpr lambda [PR107280]

    We crash here since r10-3661, the store_init_value hunk in particular.
    Before, we called cp_fully_fold_init, so e.g.

      {.str=VIEW_CONVERT_EXPR<char[8]>("")}

    was folded into

      {.str=""}

    but now we don't fold and keep the VCE around, and it causes trouble in
    cxx_eval_store_expression: in the !refs->is_empty () loop we descend on
    .str's initializer but since it's wrapped in a VCE, we skip the STRING_CST
    check and then crash on the CONSTRUCTOR_NO_CLEARING.

            PR c++/107280

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_store_expression): Strip location
wrappers.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/constexpr-lambda28.C: New test.

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

* [Bug c++/107280] [10/11/12/13 Regression] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
                   ` (5 preceding siblings ...)
  2023-03-15 18:28 ` cvs-commit at gcc dot gnu.org
@ 2023-03-15 18:29 ` cvs-commit at gcc dot gnu.org
  2023-03-15 18:30 ` [Bug c++/107280] [10/11 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-15 18:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

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

commit r12-9263-ga1ebe3f7f9c14e66df2ae56138c495cad33c7ee4
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Mar 10 10:14:20 2023 -0500

    c++: ICE with constexpr lambda [PR107280]

    We crash here since r10-3661, the store_init_value hunk in particular.
    Before, we called cp_fully_fold_init, so e.g.

      {.str=VIEW_CONVERT_EXPR<char[8]>("")}

    was folded into

      {.str=""}

    but now we don't fold and keep the VCE around, and it causes trouble in
    cxx_eval_store_expression: in the !refs->is_empty () loop we descend on
    .str's initializer but since it's wrapped in a VCE, we skip the STRING_CST
    check and then crash on the CONSTRUCTOR_NO_CLEARING.

            PR c++/107280

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_store_expression): Strip location
wrappers.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/constexpr-lambda28.C: New test.

    (cherry picked from commit be20dcc359bcc4677c5b9ce011d3cd7b4ce94a64)

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

* [Bug c++/107280] [10/11 Regression] ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928
  2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
                   ` (6 preceding siblings ...)
  2023-03-15 18:29 ` cvs-commit at gcc dot gnu.org
@ 2023-03-15 18:30 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-03-15 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12/13 Regression]    |[10/11 Regression] ICE:
                   |ICE: tree check: expected   |tree check: expected
                   |constructor, have           |constructor, have
                   |view_convert_expr in        |view_convert_expr in
                   |cxx_eval_store_expression,  |cxx_eval_store_expression,
                   |at cp/constexpr.cc:5928     |at cp/constexpr.cc:5928
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2023-03-15 18:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 19:16 [Bug c++/107280] New: ICE: tree check: expected constructor, have view_convert_expr in cxx_eval_store_expression, at cp/constexpr.cc:5928 jwjagersma at gmail dot com
2022-10-17 11:42 ` [Bug c++/107280] " marxin at gcc dot gnu.org
2022-10-17 20:47 ` mpolacek at gcc dot gnu.org
2023-03-08 22:08 ` [Bug c++/107280] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
2023-03-08 22:40 ` mpolacek at gcc dot gnu.org
2023-03-08 22:46 ` mpolacek at gcc dot gnu.org
2023-03-15 18:28 ` cvs-commit at gcc dot gnu.org
2023-03-15 18:29 ` cvs-commit at gcc dot gnu.org
2023-03-15 18:30 ` [Bug c++/107280] [10/11 " mpolacek 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).