https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99211
Bug ID: 99211 Summary: gcc fails on program which overrides __builtin_clzll Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zhan3299 at purdue dot edu Target Milestone: --- GCC fails to compile the attached code: https://godbolt.org/z/sdqq3M One interesting thing is that, only when we override __builtin_clzll this issue will occur. If we replace the __builtin_clzll as any other builtin function (e.g., __builtin_expect), GCC will accept the program with a conflicting type warning: https://godbolt.org/z/5c45T6 For other compilers, Clang rejects such conflicts with built-in functions: https://godbolt.org/z/9WzTKP Icc accepts and successfully compiles it (with warnings): https://godbolt.org/z/W4zK89 $ cat test.c struct S { int a; }; struct S __builtin_clzll(long x) { if (x == 1) { struct S y = { .a = 1 }; return y; } else { struct S y = { .a = __builtin_clzll(1).a + 1 }; return y; } } int main() { return __builtin_clzll(10).a; } $ gcc test.c test.c: In function '__builtin_clzll': test.c:10:16: internal compiler error: in wide_int_to_tree_1, at tree.c:1644 10 | struct S y = { .a = __builtin_clzll(1).a + 1 }; | ^ 0x1a31d99 internal_error(char const*, ...) ???:0 0x6877ad fancy_abort(char const*, int, char const*) ???:0 0x9bed4a fold_build_call_array_loc(unsigned int, tree_node*, tree_node*, int, tree_node**) ???:0 0x6e1010 build_function_call_vec(unsigned int, vec<unsigned int, va_heap, vl_ptr>, tree_node*, vec<tree_node*, va_gc, vl_embed>*, vec<tree_node*, va_gc, vl_embed>*, tree_node*) ???:0 0x7322e9 c_parse_file() ???:0 0x7a02c2 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.