http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54741



             Bug #: 54741

           Summary: GCC 4.4, 4.5, 4.6 4.7 (probably 4.8) Generates

                    un-usable code on AVX supported CPUs (FreeBSD)

    Classification: Unclassified

           Product: gcc

           Version: 4.6.4

            Status: UNCONFIRMED

          Severity: major

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: ace.of.zeros...@gmail.com





Created attachment 28297

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28297

both test.ii and test.s files from save-temp output



It's been quite a while that this bug is around with GCC 4.4+ on FreeBSD

systems (at least 8.2-Release and 9.0-Release which tested by me). If you have

a sandy-bridge or ivy-bridge cpu a code like this get killed by SIGILL when

compiled using -march=native:



#include <iostream>

#include <string>

#include <unordered_map>



int main() {

    std::unordered_map<std::string, std::string> hash; 

    std::cout << "Hello, World!" << std::endl;

    return 0;

}



# g++46 -std=c++0x -o test test.cpp

# ./test 

Hello, World!



# g++46 -std=c++0x -march=native -o test test.cpp

# ./test

Illegal instruction: 4



This is gdbs output:

Program received signal SIGILL, Illegal instruction.

0x00000000004011dc in std::_Hashtable<std::string, std::pair<std::string const,

std::string>, std::allocator<std::pair<std::string const, std::string> >,

std::_Select1st<std::pair<std::string const, std::string> >,

std::equal_to<std::string>, std::hash<std::string>,

std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,

std::__detail::_Prime_rehash_policy, false, false, true>::_Hashtable ()



I know the code above is using C++11 standard headers, but this bug is not a

C++11 related bug, the code above is just a known example to me. If you look at

this thread (which was opened by me nearly 1.5 years ago) on FreeBSD forums

http://forums.freebsd.org/showthread.php?t=23535 you'll see even C code (GCC

itself and nearly anything compiled by -march=native on my system) affected by

this bug.





# g++46 -v -save-temps -std=c++0x -march=native -o test test.cpp

Using built-in specs.

COLLECT_GCC=g++46

COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/lto-wrapper

Target: x86_64-portbld-freebsd9.0

Configured with: ./../gcc-4.6-20120831/configure --disable-nls

--enable-languages=c,c++,objc,fortran --libdir=/usr/local/lib/gcc46

--libexecdir=/usr/local/libexec/gcc46 --program-suffix=46

--with-as=/usr/local/bin/as --with-gmp=/usr/local

--with-gxx-include-dir=/usr/local/lib/gcc46/include/c++/

--with-ld=/usr/local/bin/ld --with-libiconv-prefix=/usr/local

--with-pkgversion='FreeBSD Ports Collection' --with-system-zlib

--disable-libgcj --prefix=/usr/local --mandir=/usr/local/man

--infodir=/usr/local/info/gcc46 --build=x86_64-portbld-freebsd9.0

Thread model: posix

gcc version 4.6.4 20120831 (prerelease) (FreeBSD Ports Collection) 

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-march=native' '-o' 'test'

'-shared-libgcc'

 /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/cc1plus -E -quiet

-v test.cpp -march=corei7-avx -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt

-mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mavx -msse4.2

-msse4.1 -mno-rdrnd -mno-f16c -mno-fsgsbase --param l1-cache-size=32 --param

l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=corei7-avx -std=c++0x

-fpch-preprocess -o test.ii

ignoring nonexistent directory

"/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/../../../../../x86_64-portbld-freebsd9.0/include"

#include "..." search starts here:

#include <...> search starts here:

 /usr/local/lib/gcc46/include/c++/

 /usr/local/lib/gcc46/include/c++//x86_64-portbld-freebsd9.0

 /usr/local/lib/gcc46/include/c++//backward

 /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/include

 /usr/local/include

 /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/include-fixed

 /usr/include

End of search list.

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-march=native' '-o' 'test'

'-shared-libgcc'

 /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/cc1plus

-fpreprocessed test.ii -march=corei7-avx -mcx16 -msahf -mno-movbe -maes

-mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi

-mno-tbm -mavx -msse4.2 -msse4.1 -mno-rdrnd -mno-f16c -mno-fsgsbase --param

l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144

-mtune=corei7-avx -quiet -dumpbase test.cpp -auxbase test -std=c++0x -version

-o test.s

GNU C++ (FreeBSD Ports Collection) version 4.6.4 20120831 (prerelease)

(x86_64-portbld-freebsd9.0)

    compiled by GNU C version 4.6.4 20120831 (prerelease), GMP version 5.0.5,

MPFR version 3.1.1, MPC version 0.9

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

GNU C++ (FreeBSD Ports Collection) version 4.6.4 20120831 (prerelease)

(x86_64-portbld-freebsd9.0)

    compiled by GNU C version 4.6.4 20120831 (prerelease), GMP version 5.0.5,

MPFR version 3.1.1, MPC version 0.9

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: f66add45a86dc64383d28918a222f366

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-march=native' '-o' 'test'

'-shared-libgcc'

 /usr/local/bin/as -v -o test.o test.s

GNU assembler version 2.22 (x86_64-portbld-freebsd9.0) using BFD version (GNU

Binutils) 2.22

COMPILER_PATH=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/../../../../../x86_64-portbld-freebsd9.0/bin/

LIBRARY_PATH=/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/../../../../../x86_64-portbld-freebsd9.0/lib/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/../../../:/lib/:/usr/lib/

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-march=native' '-o' 'test'

'-shared-libgcc'

 /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/collect2

--eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 -o test /usr/lib/crt1.o

/usr/lib/crti.o

/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/crtbegin.o

-L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4

-L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/../../../../../x86_64-portbld-freebsd9.0/lib

-L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/../../.. test.o

-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc

/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd9.0/4.6.4/crtend.o

/usr/lib/crtn.o

GNU ld (GNU Binutils) 2.22

  Supported emulations:

   elf_x86_64_fbsd

   elf_i386_fbsd

   elf_x86_64

   elf_i386

   elf_l1om

   elf_l1om_fbsd

   elf_k1om

   elf_k1om_fbsd

Reply via email to