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

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is wrong.  tree_expr_nonzero_p is an optimization which relies on lack of
UB in the program, in many cases the non-zero property is determined by
assuming a program doesn't have UB and if so, this has some range or some
constant bits etc.
While ubsan is meant to check for invalid programs.  So, it has to try hard to
avoid relying on lack of UB as much as possible because it is meant to diagnose
UB.
So, sure, if it can prove something must be non-NULL regardless of whether the
program is valid or not, it can avoid the check.  But if the check does or
could rely on lack of UB, we need to avoid it.  So using e.g. VRP info is
no-way, etc.

Reply via email to