http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60729
Bug ID: 60729 Summary: Compiler failure for combination of -ftrapv and -O3: compiler error: in prepare_cmp_insn Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rppawlo at sandia dot gov Created attachment 32514 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32514&action=edit test file Hi, I'm running stock Ubuntu 13.10 and get a g++ compiler error when using a certain commbination of compiler options. The attached file reproduces the bug: *************************BEGIN FILE*********************** // This test generates an inernal compiler failure in g++ 4.8.1 on // ubuntu 13.10. The combination of -O3 and -ftrapv causes the issue. // You can drop to -O2 or remove -ftrapv to fix. // The following compile works: // g++ -O3 -c test.cpp // g++ -O2 -ftrapv -c test.cpp // The following compile fails: // g++ -ftrapv -O3 -c test.cpp #include <cmath> void doSomething(int dim, double *Y, double *A) { for (int k=0; k<dim; k++) Y[k] += std::abs(A[k]); } *************************END FILE*********************** Here's the output: rppawlo@drekar:~$ g++ -O3 -c test.cpp rppawlo@drekar:~$ g++ -O2 -ftrapv -c test.cpp rppawlo@drekar:~$ g++ -ftrapv -O3 -c test.cpp test.cpp: In function ‘void doSomething(int, double*, double*)’: test.cpp:17:27: internal compiler error: in prepare_cmp_insn, at optabs.c:4190 Y[k] += std::abs(A[k]); ^ Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions. Preprocessed source stored into /tmp/cccvQgai.out file, please attach this to your bugreport. rppawlo@drekar:~$ Here's some info about my machine/environment: rppawlo@drekar:~$ g++ --version g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. rppawlo@drekar:~$ uname -a Linux drekar 3.11.0-18-generic #32-Ubuntu SMP Tue Feb 18 21:11:14 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux