https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106990
Bug ID: 106990
Summary: Missing TYPE_OVERFLOW_SANITIZED checks in match.pd
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: kristerw at gcc dot gnu.org
Target Milestone: ---
When UBSan is used, match.pd disables simplifications that can remove UB. But
two simplifications are missing TYPE_OVERFLOW_SANITIZED checks, making the two
tests below fail to report UB when compiled with -fsanitize=undefined.
/* (~X - ~Y) -> Y - X. */
int main(void)
{
volatile int x = -1956816001;
volatile int y = 1999200512;
return ~x - ~y;
}
/* -x & 1 -> x & 1. */
int main(void)
{
volatile int x = 0x80000000;
return -x & 1;
}