https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81088
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-06-14
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We associate to
(1 - (int) s) + 2147483647
without -fsanitize=undefined which is fine. But with -fsanitize=undefined
we end up with:
;; Function main (null)
;; enabled by -tree-original
{
i = if (SAVE_EXPR <(int) y>;, SAVE_EXPR <(int) y> == 0 || (SAVE_EXPR <(int)
y>;, 0);)
{
__builtin___ubsan_handle_divrem_overflow (&*.Lubsan_data0, 0, (unsigned
long) SAVE_EXPR <(int) y>);
}
else
{
<<< Unknown tree: void_cst >>>
}, SAVE_EXPR <(int) y>;, -(int) s + -2147483648(OVF);;
return 0;
}
this goes wrong somewhere when fully folding
-((int) s + (int) ~(if (SAVE_EXPR <(int) y>;, SAVE_EXPR <(int) y> == 0 ||
(SAVE_EXPR <(int) y>;, 0);)
{
__builtin___ubsan_handle_divrem_overflow (&*.Lubsan_data0, 0, (unsigned
long) SAVE_EXPR <(int) y>);
}
else
{
<<< Unknown tree: void_cst >>>
}, (unsigned int) (0 / SAVE_EXPR <(int) y>);)) + 2147483647