[Bug c++/59163] New: program compiled with g++ -O3 segfaults
donnyjward at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Nov 17 22:44:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59163
Bug ID: 59163
Summary: program compiled with g++ -O3 segfaults
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: donnyjward at gmail dot com
Created attachment 31232
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31232&action=edit
Stripped preprocessed C++ source.
The attached test case crashes (segmentation fault) when run. It is a
preprocessed file where I stripped just about everything from <algorithm>
except std::for_each.
gcc -v:
~/src $ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/app/gcc/4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./gcc-4.8.2/configure --prefix=/app/gcc/4.8.2
--enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 4.8.2 (GCC)
~/src $
The complete command line that triggers the bug:
g++ -O3 -std=c++11 -Wall -Wextra bug2.ii
...then run the output program to see the segmentation fault
I tried building with:
g++ -O3 -std=c++11 -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -Wall -Wextra bug2.ii
...and the same crash occurs.
The compiler outputs no messages (no warnings errors etc).
The program runs without crashing if compiled with -O0, -O1, -O2, or -Os.
I compiled with the latest version of clang++ bundled with Mac's XCode, trying
each optimization level and the program runs fine. Same with the latest version
of MSVC (Visual Studio 2013).
The gdb segfault and backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x00000000004007a7 in Quaternion::slerp(Quaternion const&, Quaternion const&)
() at bug2.ii:82
82 {
(gdb) bt
#0 0x00000000004007a7 in Quaternion::slerp(Quaternion const&, Quaternion
const&) () at bug2.ii:82
#1 0x0000000000400475 in main () at bug2.ii:97
(gdb)
Extra observations:
If I comment out "int parent" in the struct definition so that the struct
becomes
struct Joint
{
//int parent;
Quaternion orient;
};
the program no longer segfaults when compiled/run.
More information about the Gcc-bugs
mailing list