https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120095
Bug ID: 120095 Summary: ICE in convert_mode_scalar when casting double (*)(double) to int (*)(float) and calling it with a large argument Product: gcc Version: 15.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mario.rodriguezb1 at um dot es Target Milestone: --- GCC crashes with an internal compiler error when casting standard math functions like cos and fabs (with type double (*)(double)) to a mismatched function pointer type int (*)(float) ``` #include <limits.h> #include <stdlib.h> #include <stdio.h> #include <math.h> int main(void) { int (*c)(float); if (c = (int(*)(float)) cos) puts("success"); if (c = (int(*)(float)) fabs) puts("failure"); if (c && c((float) INT_MAX)) abort(); return EXIT_SUCCESS; } ``` ``` <source>:11:12: internal compiler error: in convert_mode_scalar, at expr.cc:336 11 | if (c && c((float) INT_MAX)) | ^~~~~~~~~~~~~~~~~~ 0x20bcdd5 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x20ce326 internal_error(char const*, ...) ???:0 0x7a56c6 fancy_abort(char const*, int, char const*) ???:0 0xa5111d store_expr(tree_node*, rtx_def*, int, bool, bool) ???:0 ``` It happens since 4.9 to last version using any optimization flag, -O1, -O2... https://gcc.godbolt.org/z/T4aK6vooW