https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80346

--- Comment #15 from Jeffrey A. Law <law at redhat dot com> ---
I was looking pretty hard for something the compiler could use to avoid the
problematical paths.  That's always my first approach since doing so removes
the warning and generates better code.

I just couldn't find anything useful.

For the undefined behavior path that can't be removed, my preference is to
insert a trap rather than going into the else clause -- hitting the trap stops
the program cold which is far safer from a security standpoint.  That's what we
do with things like dereferencing a NULL pointer or division by zero.  If our
out-of-bounds array bounds analysis was better, we'd be doing it there too.

Reply via email to