https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120277
Bug ID: 120277 Summary: Crash at -O2: in upper_bound, at value-range.h:1181 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: yunboni at smail dot nju.edu.cn Target Milestone: --- This code crashes at -O2: int a, b; int c(int d, long e) { switch (d) { case 129: a = 1; case 128: break; default: return 1; } *(int *)e = 0; } void f(int d, long e) { c(d, e); } void g() { int h = b * sizeof(int); f(h + 7, h); } void main() {} Compiler Explorer: https://godbolt.org/z/9f9jcon4q Crash: <source>:18:1: internal compiler error: in upper_bound, at value-range.h:1181 18 | void main() {} | ^~~~ Backtrace: 0x2618675 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x26363e6 internal_error(char const*, ...) ???:0 0x9f3274 fancy_abort(char const*, int, char const*) ???:0 0x232440f fold_using_range::range_of_range_op(vrange&, gimple_range_op_handler&, fur_source&) ???:0 0x2324d12 fold_using_range::fold_stmt(vrange&, gimple*, fur_source&, tree_node*) ???:0 0x230d643 gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*) ???:0 0x14f75b3 range_query::value_of_stmt(gimple*, tree_node*) ???:0 0x1361117 substitute_and_fold_dom_walker::before_dom_children(basic_block_def*) ???:0 0x22af8f7 dom_walker::walk(basic_block_def*) ???:0 0x136007b substitute_and_fold_engine::substitute_and_fold(basic_block_def*) ???:0 0x14bc58e execute_ranger_vrp(function*, bool) ???:0 Bisected to https://github.com/gcc-mirror/gcc/commit/c40a4cc2d943d8572a62f21d3eb1d4171e51d5ac