From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 13ED83858D28; Wed, 17 Nov 2021 15:31:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13ED83858D28 From: "wqpfelix at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103303] New: compiler have trouble to point to the correct destructor address while for large align objects with complex inheritance while destruct object Date: Wed, 17 Nov 2021 15:30:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wqpfelix at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2021 15:31:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103303 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=3D51825&action=3Dedit 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:=20 while running with the following compiler ```sh $Compiler/bin/g++ -v Using built-in specs. COLLECT_GCC=3D/net/binlib/build-kits/build-kit-20191029-x86_64-pc-linux-gnu= -gcc-8.2.0-gcc82_u18_v3/bin/g++ COLLECT_LTO_WRAPPER=3D/net/binlib/build-kits/build-kit-20191029-x86_64-pc-l= inux-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=3D{PathTo_gcc82_u18_v3} --with-mpfr=3D{PathTo_gcc82_u18_v3} --with-mpc=3D{PathTo_gcc82_u18_v3} --with-isl=3D{PathTo_gcc82_u18_v3} --prefix=3D{PathTo_gcc82_u18_v3} --exec-prefix=3D{PathTo_gcc82_u18_v3} --enable-languages=3Dc,c++ --enable-s= hared --enable-static --enable-threads=3Dposix --disable-host-shared --enable-lto --with-ld=3D{PathTo_gcc82_u18_v3}/bin/ld --target=3Dx86_64-pc-linux-gnu --with-sysroot=3D/. --with-gxx-include-dir=3D{PathTo_gcc82_u18_v3}/include/libstdc++ --disable-multilib --verbose Thread model: posix gcc version 8.2.0 (GCC) ``` on C++ program with ```C++ #include #include struct alignas(16) largeAligned{ // change to 8, no crash uint32_t u_arr[128]; }; template struct ICategory: public virtual Base{ ICategory(){ std::cout << __PRETTY_FUNCTION__ << std::endl; } }; struct PureInterfaceHandler{ virtual ~PureInterfaceHandler() =3D default; }; template 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 =3D ICategory; using Category1 =3D ICategory; struct ProblematicNotifier: TemplateNotifier{}; int main(){ static_assert(alignof(ProblematicNotifier) =3D=3D 16, "128 is great" ); static_assert( alignof(std::max_align_t) =3D=3D 16, "16? is great" ); ProblematicNotifier* objPtr =3D new ProblematicNotifier(); delete objPtr; std::cout << "Done" << std::endl; } ``` with:=20 $Compiler/bin/g++ -I $Compiler/include -I $Compiler/include/libstdc++ crash.cpp -O3 I found:=20 Program received signal SIGSEGV, Segmentation fault. 0x000000000040228a in ProblematicNotifier::~ProblematicNotifier() () on instruction:=20 0x40228a <_ZN19ProblematicNotifierD0Ev+202> movaps %xmm0,0x8(%rbx) where (gdb) x/i $rbx 0x417e70: mov $0x34,%al it looks like compiler generates=20 movaps with offset 0x8 while handling aligned object, while is not expected= for movaps=