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>(); }
          |                   ~~~~~~~~~~~~~~~^~
    ...

Reply via email to