https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121580
Bug ID: 121580 Summary: [ICE] internal compiler error: in fold_convert_loc, at fold-const.cc:2670 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: njuwy at smail dot nju.edu.cn Target Milestone: --- Compiler Explorer: https://godbolt.org/z/3r3MxTdET The crash triggering program (compile with `gcc-16 -O0`): ``` #include <stddef.h> #include <stdlib.h> #include <stdio.h> typedef typeof(nullptr) nullptr_t; static long double process_array(int *data, size_t len, nullptr_t np) { size_t i = 0; long double acc = 0.0l; int threshold = len > 5 ? data[5] : 0; while (i < len) { if (np != nullptr) { acc += (long double)(data[i]); if (acc > threshold) { acc = (acc < 100.0l) ? acc : 100.0l; for (size_t j = i + 1; j < len && j < i + 3; ++j) { data[j] ^= (int)(acc / 10.0l); } threshold = (int)(acc / 2.0l); } } i += (acc < 50.0l) ? 1 : 2; } printf("Final accumulator: %.2Lf\n", acc); return acc; } int main(void) { int values[] = {10, 20, 5, 30, 40, 15, 25}; size_t n = sizeof(values) / sizeof(values[0]); nullptr_t nullp = nullptr; process_array(values, n, nullp); if (nullp == nullptr) { puts("nullptr_t comparison successful."); } return EXIT_SUCCESS; } ``` The crash output: ``` during GIMPLE pass: profile_estimate <source>: In function 'process_array': <source>:34:1: internal compiler error: in fold_convert_loc, at fold-const.cc:2670 34 | } | ^ 0x2558885 diagnostics::context::diagnostic_impl(rich_location*, diagnostics::metadata const*, diagnostics::option_id, char const*, __va_list_tag (*) [1], diagnostics::kind) ???:0 0x254dea6 internal_error(char const*, ...) ???:0 0xa0607a fancy_abort(char const*, int, char const*) ???:0 0x136a082 number_of_iterations_exit(loop*, edge_def*, tree_niter_desc*, bool, bool, basic_block_def**) ???:0 0x109dfb1 tree_estimate_probability(bool) ???: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. Compiler returned: 1 ```