https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108691
Bug ID: 108691 Summary: ICE when compiling for AArch64 with BTI protection at -O1 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: david.spickett at linaro dot org Target Milestone: --- Created attachment 54416 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54416&action=edit Output from -freport-bug This code: ``` extern int __attribute__((returns_twice)) setjmp(void*); void bbb(void) { int (*fnptr)(void*) = setjmp; fnptr(0); } ``` Causes an ICE when compiled with gcc trunk. ``` during GIMPLE pass: cddce <source>: In function 'bbb': <source>:6:1: internal compiler error: in eliminate_unnecessary_stmts, at tree-ssa-dce.cc:1512 6 | } | ^ Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 ``` https://godbolt.org/z/6dEMEbEG8 Compiling at -O0, or calling setjmp directly avoids the crash. There is no crash with gcc 12.2. Also calling setjmp directly after using the function pointer avoids the crash. One thing that is happening here is that gcc is converting the indirect call into a direct one. Perhaps when that is the only call in the function, that's the problematic situation. For context, this is not from real code. It's a clang test case for bti protection of returns twice calls. Either way, the compiler shouldn't crash and if there's something wrong with the source it should say so.