https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56917
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Author: mpolacek Date: Wed Mar 11 10:37:38 2015 New Revision: 221346 URL: https://gcc.gnu.org/viewcvs?rev=221346&root=gcc&view=rev Log: Backported from mainline 2014-12-04 Marek Polacek <pola...@redhat.com> PR middle-end/56917 * fold-const.c (fold_unary_loc): Perform the negation in A's type when transforming ~ (A - 1) or ~ (A + -1) to -A. * c-c++-common/ubsan/pr56917.c: New test. Added: branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/ubsan/pr56917.c Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/fold-const.c branches/gcc-4_9-branch/gcc/testsuite/ChangeLog