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

            Bug ID: 120878
           Summary: ICE: in adjust_temp_type, at cp/constexpr.cc:1791
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rush102333 at gmail dot com
  Target Milestone: ---

Starts to baliling out since gcc-11: https://godbolt.org/z/3aWo3dsMs

Simplified test:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

struct GLS {
int a;
};
auto GL2 = [](auto a); { return GLS{a}; };
constexpr GLS (*fp3)(char) = GL2;
static_assert(fp3('3').a == '3', "");

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Stack Dump:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<source>: In lambda function:
<source>:4:22: error: expected '{' before ';' token [-Wtemplate-body]
    4 | auto GL2 = [](auto a); { return GLS{a}; };
      |                      ^
<source>: At global scope:
<source>:4:24: error: expected unqualified-id before '{' token
    4 | auto GL2 = [](auto a); { return GLS{a}; };
      |                        ^
<source>:5:30: error: invalid user-defined conversion from '<lambda(auto:1)>'
to 'GLS (*)(char)' [-fpermissive]
    5 | constexpr GLS (*fp3)(char) = GL2;
      |                              ^~~
<source>:4:12: note: candidate is: 'constexpr<lambda(auto:1)>::operator
decltype
(((const<lambda(auto:1)>*)0)->operator()<auto:1>(static_cast<auto:1&&>(<anonymous>)))
(*)(auto:1)() const [with auto:1 = char; decltype
(((const<lambda(auto:1)>*)0)->operator()<auto:1>(static_cast<auto:1&&>(<anonymous>)))
= void]' (near match)
    4 | auto GL2 = [](auto a); { return GLS{a}; };
      |            ^
<source>:4:12: note: no known conversion from 'void (*)(char)' to 'GLS
(*)(char)'
<source>:6:18: internal compiler error: in adjust_temp_type, at
cp/constexpr.cc:1791
    6 | static_assert(fp3('3').a == '3', "");
      |               ~~~^~~~~
0x2844425 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x2866fc6 internal_error(char const*, ...)
        ???:0
0xaede72 fancy_abort(char const*, int, char const*)
        ???:0
0xb6b911 maybe_constant_value(tree_node*, tree_node*, mce_value)
        ???:0
0xde82a7 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
        ???:0
0xb288b4 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
        ???:0
0xdd98b2 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
        ???:0
0xd166e3 c_parse_file()
        ???:0
0xe7e469 c_common_parse_file()
        ???:0
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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to