https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127506
Bug ID: 127506
Summary: ICE in is_within_lifetime, at cp/constexpr.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/E76KdPsYr
Reproducer:
```
template <class T> consteval bool foo(const T *p) {
return __builtin_is_within_lifetime(p);
}
struct S {
char a;
};
constexpr S s = { int b; };
bool bar() { return (!foo(&s.a)); }
```
Backtrace:
<source>:8:19: error: expected primary-expression before 'int'
8 | constexpr S s = { int b; };
| ^~~
<source>:8:19: error: expected '}' before 'int'
8 | constexpr S s = { int b; };
| ~ ^~~
<source>:8:19: note: probably missing a comma or an operator before
<source>: In function 'bool bar()':
<source>:10:26: in 'constexpr' expansion of 'foo<char>((& s.S::a))'
10 | bool bar() { return (!foo(&s.a)); }
| ~~~^~~~~~
<source>:2:38: internal compiler error: in is_within_lifetime, at
cp/constexpr.cc:2688
2 | return __builtin_is_within_lifetime(p);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
0x2c54f68 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2c49bab internal_error(char const*, ...)
???:0
0xb7d362 fancy_abort(char const*, int, char const*)
???:0
0xbeba1d cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xbea8a4 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xbec0d7 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xbeb8bc cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xbeba1d cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xc06680 maybe_constant_value(tree_node*, tree_node*, mce_value)
???:0
0xe76824 finish_unary_op_expr(unsigned long, tree_code, cp_expr, int)
???:0
0xdd5ff3 c_parse_file()
???:0
0xf69879 c_common_parse_file()
???:0
This ICE is trunk only:
https://godbolt.org/z/KM4jT33Gq