https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106163
Bug ID: 106163 Summary: generic-match does not honor -fnon-call-exceptions -fno-delete-dead-exceptions Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ian at airs dot com Target Milestone: --- When using -fnon-call-exceptions -fno-delete-dead-exceptions memory operations that are not marked TREE_THIS_NOTRAP should not be removed from the execution path. However, the generic_simplify function, at least, does not honor this. This test case, when compiled with -fnon-call-exceptions -fno-delete-dead-exceptions, should exit with a zero status. However, it currently fails, because "i = *p ^ *p;" is simplified to "i = 0;". // { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } // { dg-additional-options "-fexceptions -fnon-call-exceptions -fno-delete-dead-exceptions" } #include <signal.h> #include <stdlib.h> #include <string.h> static void sighandler (int signo, siginfo_t* si, void* uc) { throw (5); } struct S { void *p1, *p2; }; struct S v; __attribute__ ((noinline)) int dosegv () { int *p = 0; int i __attribute__((unused)) = 0; i = *p ^ *p; return 0; } int main () { struct sigaction sa; memset (&sa, 0, sizeof sa); sa.sa_sigaction = sighandler; sigaction (SIGSEGV, &sa, NULL); sigaction (SIGBUS, &sa, NULL); try { dosegv (); } catch (int x) { return (x != 5); } return 1; }