https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106075
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-06-24 CC| |rguenth at gcc dot gnu.org --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Related: int a = 1; int c,d; void test() { a=12345; c/d; a=1; } where the possibly throwing division (by zero) does not have virtual operands. Likewise void __attribute__((noreturn,const)) foo () { longjmp (&buf); } int a = 1; int c,d; void test() { a=12345; foo (); a=1; } but then we can simply declare 'const' invalid on 'foo'. For the non-VOP case we'd need to assign a "context" counter to stmts (in UID for example) and increment it when seeing a possible (implicit) control flow terminating statement. When the DSE walk discovers a new context it has to consider that a use. The expense is an extra whole-IL walk over the function [with -fnon-call-exceptions]. Note there's also the possibility to create a const externally throwing function but its semantics are disputed (see another PR for that).