Created attachment 38665 [details] Reproducer The test fails only in case array sizes are set in a separate file. init.cpp - initializes the array, func.cpp - accesses the elements. The test fails with 'std::out_of_range', but only on westmere -O3. Other targets/optimizations and compilers seem to work. Reproduce: > g++ -std=c++11 -static-libgcc -static-libstdc++ -O3 -march=westmere -o out func.cpp init.cpp > ./out Output: terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 0) Aborted (core dumped) > gcc -v: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/export/users/amitrokh/gcc_trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /export/users/gnutester/stability/svn/trunk/configure --with-arch=corei7 --with-cpu=corei7 --enable-clocale=gnu --with-system-zlib --enable-shared --with-demangler-in-ld --enable-cloog-backend=isl --with-fpmath=sse --with-pkgversion=Revision=237240/svn-rev:237241/ --prefix=/export/users/gnutester/stability/work/trunk/64/install --enable-languages=c,c++,fortran,java,lto Thread model: posix gcc version 7.0.0 20160608 (experimental) (Revision=237240/svn-rev:237241/)
Can you try this again? There has been some patches which might have fixed this.
It works now, thank you. However, the unreduced test case now fails with a segfault (again, only on westmere). I will try to reduce it and create a tracker =)