https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81237
Bug ID: 81237 Summary: Cannot link when class methods compiled with different levels of vectorization Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ravi.kappiy...@cd-adapco.com Target Milestone: --- I have 4 files (2 CPP files, 1 header file, and 1 Makefile), shown below: **test.h** #ifndef test_h_ #define test_h_ #include <string> class A { public: virtual ~A() {} protected: }; class B { public: virtual std::string const func() const = 0; protected: B() {} virtual ~B() {} }; class C : public A , public B { public: ~C(); private: std::string const func() const; }; #endif **test.cpp** #include "test.h" C::~C() {} **test2.cpp** #include "test.h" std::string const C::func() const { return 0; } **Makefile** all: ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu7.1.0/bin/g++ -O3 --param inline-unit-growth=1000 -fPIC -o test2.o -c test2.cpp ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu7.1.0/bin/g++ -fPIC -O3 --param inline-unit-growth=1000 -shared -z defs -Wl,--as-needed -shared -Wl,-soname,libTest2.so -o libTest2.so test2.o ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu7.1.0/bin/g++ -O3 --param inline-unit-growth=1000 -fPIC -mavx512f -fabi-version=6 -o test.o -c test.cpp ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu7.1.0/bin/g++ -fPIC -O3 --param inline-unit-growth=1000 -shared -z defs -Wl,--as-needed -shared -Wl,-soname,libTest.so -o libTest.so test.o libTest2.so old: ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu6.2.0/bin/g++ -O3 --param inline-unit-growth=1000 -fPIC -o test2.o -c test2.cpp ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu6.2.0/bin/g++ -fPIC -O3 --param inline-unit-growth=1000 -shared -z defs -Wl,--as-needed -shared -Wl,-soname,libTest2.so -o libTest2.so test2.o ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu6.2.0/bin/g++ -O3 --param inline-unit-growth=1000 -fPIC -mavx512f -fabi-version=6 -o test.o -c test.cpp ${MIRROR_HOME}/compilers/linux-x86_64-2.10.1/gnu6.2.0/bin/g++ -fPIC -O3 --param inline-unit-growth=1000 -shared -z defs -Wl,--as-needed -shared -Wl,-soname,libTest.so -o libTest.so test.o libTest2.so * **test2.cpp** is compiled with SSE2 instructions to create **libTest2.so** * **test.cpp** is compiled with AVX-512 instructions (the flags "-mavx512f -fabi-version=6" are added to it's compile) * If both CPP files are instead compiled with the same vectorization level (via the removal of the extra flags for **test.cpp** or the addition of the same flags for **test2.cpp**), then the compile works as expected. * The linker appears to be getting confused when some of the methods in the class are compiled with one vectorization level, while other methods are compiled with another, causing the "undefined reference" error. * As far as I am aware, it is not illegal via the standard to compile certain methods of a class with one level of vectorization and not other methods - this appears to be a compiler bug. * When using "make old" (i.e., using GNU 6.2 instead of GNU 7.1), the compile works as expected even when using different levels of vectorization.