https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118525
Bug ID: 118525
Summary: [14/15 Regression] ICE after error dealing consteval
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: error-recovery, ice-checking, ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Blocks: 118483
Target Milestone: ---
Take:
```
consteval int id (int i) { return i; }
void
g (int i)
{
1 ? 1 : id (i) ^ 1; // { dg-error "call to consteval function|'i' is not a
constant expression" }
}
```
Right now in GCC 14+ we ICE inside match and simplify:
```
<source>: In function 'void g(int)':
<source>:6:14: error: call to consteval function 'id(i)' is not a constant
expression
6 | 1 ? 1 : id (i) ^ 1; // { dg-error "call to consteval function|'i' is
not a constant expression" }
| ~~~^~~
<source>:6:15: error: 'i' is not a constant expression
6 | 1 ? 1 : id (i) ^ 1; // { dg-error "call to consteval function|'i' is
not a constant expression" }
| ^
<source>:7:1: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in types_match, at generic-match-head.cc:61
7 | }
| ^
0x2904915 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x291b716 internal_error(char const*, ...)
???:0
0x9d6679 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
???:0
0x1d6934a generic_simplify_BIT_XOR_EXPR(unsigned long, tree_code, tree_node*,
tree_node*, tree_node*)
???:0
0x10460da fold_binary_loc(unsigned long, tree_code, tree_node*, tree_node*,
tree_node*)
???:0
0x1067634 fold(tree_node*)
???:0
0x17e6bdc walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
???:0
0xb68583 cp_fold_function(tree_node*)
???:0
0xbb7771 finish_function(bool)
???:0
0xce643a c_parse_file()
???:0
0xe46509 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.
```
Noticed while working on PR 118483.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118483
[Bug 118483] [12/13/14/15 Regression] Missed optimization due to cast being
used more than once