This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/80281] New: Wrong constant folding


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

            Bug ID: 80281
           Summary: Wrong constant folding
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishiura-compiler at ml dot kwansei.ac.jp
  Target Milestone: ---

GCC 7.0.1 for x86_64 miscompiles the following code.

% cat test.c

int main (void)
{
        volatile int a = 0;
        long b = 2147483648L;

        int c = a % 2;
        int x = ( (int)( -b ) + c  ) % -2147483647;

        if (x != -1) __builtin_abort();

        return 0;
}
% gcc-7.0 test.c -O3
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 test.c -Os
% ./a.out
zsh: abort (core dumped)  ./a.out
% gcc-7.0 -v
Using built-in specs.
COLLECT_GCC=gcc-7.0
COLLECT_LTO_WRAPPER=/home/cappie/opt/gcc-7.0.1/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/cappie/opt/gcc-7.0.1 --disable-nls
--disable-multilib --program-suffix=-7.0 --enable-languages=c
Thread model: posix
gcc version 7.0.1 20170330 (experimental) (GCC)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]