https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127842
Bug ID: 127842
Summary: ICE in fold_convert_const_int_from_real, at
fold-const.cc
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: s.kimura.h41104 at gmail dot com
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/45fn68GoW
Reproducer:
```
auto L = [](auto a) { return a; };
constexpr char (*foo)(float) = L;
static_assert(foo(42.) == '42', "");
```
Backtrace:
<source>:4:27: warning: multi-character character constant [-Wmultichar]
4 | static_assert(foo(42.) == '42', "");
| ^~~~
<source>:2:32: error: invalid user-defined conversion from '<lambda(auto:1)>'
to 'char (*)(float)' [-fpermissive]
2 | constexpr char (*foo)(float) = L;
| ^
• 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 = float; decltype
(((const<lambda(auto:1)>*)0)->operator()<auto:1>(static_cast<auto:1&&>(<anonymous>)))
= float]' (near match)
<source>:1:10:
1 | auto L = [](auto a) { return a; };
| ^
• no known conversion from 'float (*)(float)' to 'char (*)(float)'
<source>:4:18: internal compiler error: in fold_convert_const_int_from_real, at
fold-const.cc:2182
4 | static_assert(foo(42.) == '42', "");
| ~~~^~~~~
0x2c5b2b8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2c4fefb internal_error(char const*, ...)
???:0
0xb9d350 fancy_abort(char const*, int, char const*)
???:0
0x11a2d4a fold_unary_loc(unsigned long, tree_code, tree_node*, tree_node*)
???:0
0x11a54fd fold_build1_loc(unsigned long, tree_code, tree_node*, tree_node*)
???:0
0xc1060b cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xc26a60 maybe_constant_value(tree_node*, tree_node*, mce_value)
???:0
0xef0c40 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
???:0
0xbd9784 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
???:0
0xee16b2 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
???:0
0xdf78d3 c_parse_file()
???:0
0xf8b9b9 c_common_parse_file()
???:0
This ICE goes back to gcc-11:
https://godbolt.org/z/s8rdrb6Y8