The following C++ code crashes when compiling with G++ 4.1.3, even though it is perfectly valid C++. To reproduce the bug, simply compile the program with -O2 and run it.
EXECUTION: [EMAIL PROTECTED]:~/cs/temp$ g++ -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2) [EMAIL PROTECTED]:~/cs/temp$ g++ -o a a.cc -O2 -Wall [EMAIL PROTECTED]:~/cs/temp$ ./a foo Segmentation fault (core dumped) CODE: #include <vector> #include <iostream> struct A { std::vector<double> v, w; A(); }; A::A() : v(2), w(2){ std::cerr << "foo" << std::endl; for (int i = 0; i < 2; i++){ for (int j = i+1; j < 2; j++){ w[i] -= v[i]; w[j] -= v[j]; } } } int main (){ A a; return 0; } -- Summary: Segmentation fault in G++ 4.1.3 with -O2 Product: gcc Version: 4.1.3 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: chuongdo at cs dot stanford dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34021