https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103303
Bug ID: 103303 Summary: compiler have trouble to point to the correct destructor address while for large align objects with complex inheritance while destruct object Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wqpfelix at gmail dot com Target Milestone: --- Created attachment 51825 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51825&action=edit c++ code trigger the 0x8 offset for movaps the error is reproduced on compiler explorer: https://godbolt.org/z/v8roq3641 where I can trigger this problem while gcc after 8.1 more details: while running with the following compiler ```sh $Compiler/bin/g++ -v Using built-in specs. COLLECT_GCC=/net/binlib/build-kits/build-kit-20191029-x86_64-pc-linux-gnu-gcc-8.2.0-gcc82_u18_v3/bin/g++ COLLECT_LTO_WRAPPER=/net/binlib/build-kits/build-kit-20191029-x86_64-pc-linux-gnu-gcc-8.2.0-gcc82_u18_v3/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: .../gcc/configure --with-gmp={PathTo_gcc82_u18_v3} --with-mpfr={PathTo_gcc82_u18_v3} --with-mpc={PathTo_gcc82_u18_v3} --with-isl={PathTo_gcc82_u18_v3} --prefix={PathTo_gcc82_u18_v3} --exec-prefix={PathTo_gcc82_u18_v3} --enable-languages=c,c++ --enable-shared --enable-static --enable-threads=posix --disable-host-shared --enable-lto --with-ld={PathTo_gcc82_u18_v3}/bin/ld --target=x86_64-pc-linux-gnu --with-sysroot=/. --with-gxx-include-dir={PathTo_gcc82_u18_v3}/include/libstdc++ --disable-multilib --verbose Thread model: posix gcc version 8.2.0 (GCC) ``` on C++ program with ```C++ #include <iostream> #include <cstddef> struct alignas(16) largeAligned{ // change to 8, no crash uint32_t u_arr[128]; }; template<typename Base> struct ICategory: public virtual Base{ ICategory(){ std::cout << __PRETTY_FUNCTION__ << std::endl; } }; struct PureInterfaceHandler{ virtual ~PureInterfaceHandler() = default; }; template<typename...MsgCategoryNotifierS> class TemplateNotifier : public PureInterfaceHandler, public MsgCategoryNotifierS...{ public: TemplateNotifier() { std::cout << __PRETTY_FUNCTION__ << std::endl; } virtual ~TemplateNotifier() { std::cout << __PRETTY_FUNCTION__ << std::endl; } }; struct Base1{ Base1(){ std::cout << __PRETTY_FUNCTION__ << std::endl; } virtual ~Base1(){ std::cout << __PRETTY_FUNCTION__ << std::endl; } largeAligned aligned1; }; struct Base2{ Base2(){ std::cout << __PRETTY_FUNCTION__ << std::endl; } virtual ~Base2(){ std::cout << __PRETTY_FUNCTION__ << std::endl; } largeAligned aligned2; }; using Category2 = ICategory<Base1>; using Category1 = ICategory<Base2>; struct ProblematicNotifier: TemplateNotifier<Category1, Category2>{}; int main(){ static_assert(alignof(ProblematicNotifier) == 16, "128 is great" ); static_assert( alignof(std::max_align_t) == 16, "16? is great" ); ProblematicNotifier* objPtr = new ProblematicNotifier(); delete objPtr; std::cout << "Done" << std::endl; } ``` with: $Compiler/bin/g++ -I $Compiler/include -I $Compiler/include/libstdc++ crash.cpp -O3 I found: Program received signal SIGSEGV, Segmentation fault. 0x000000000040228a in ProblematicNotifier::~ProblematicNotifier() () on instruction: 0x40228a <_ZN19ProblematicNotifierD0Ev+202> movaps %xmm0,0x8(%rbx) where (gdb) x/i $rbx 0x417e70: mov $0x34,%al it looks like compiler generates movaps with offset 0x8 while handling aligned object, while is not expected for movaps