https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68142
Bug ID: 68142
Summary: unsafe association of multiplication
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
While working on PR66313 I noticed we fail for the following with
-fsanitize=undefined
int __attribute__((noinline,noclone))
i(int a)
{
return (2 * a) * (__INT_MAX__/2 + 1);
}
int main()
{
volatile tem = i(-1);
return 0;
}
this is because we simplify the above to
;; Function i (null)
;; enabled by -tree-original
{
return a * -2147483648(OVF);
}
which is of course invalid.