From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3AC0F385841C; Wed, 17 Nov 2021 22:06:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AC0F385841C From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103303] compiler have trouble to point to the correct destructor address while for large align objects with complex inheritance while destructing object Date: Wed, 17 Nov 2021 22:06:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: keywords Message-ID: In-Reply-To: References: 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 22:06:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103303 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #1 from Andrew Pinski --- #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::uintptr_t t =3D (std::uintptr_t)this; printf("this:%lx\n", (long)(t&0xff)); printf("this->PureInterfaceHandler:%lx\n", (long)((std::uintptr_t)(PureInterfaceHandler*)this&0xff)); (printf("this->%s:%lx\n", typeid (MsgCategoryNotifierS).name(),(long)((std::uintptr_t)(MsgCategoryNotifierS*= )this&0xff)),...); std::cout << __PRETTY_FUNCTION__ << std::endl; } }; struct Base1{ Base1(){ std::cout << __PRETTY_FUNCTION__ << std::endl; std::uintptr_t t =3D (std::uintptr_t)&aligned1; printf("%lx\n", (long)(t&0xff)); } virtual ~Base1(){ std::uintptr_t t =3D (std::uintptr_t)&aligned1; printf("%lx\n", (long)(t&0xff)); std::cout << __PRETTY_FUNCTION__ << std::endl; } largeAligned aligned1; }; struct Base2{ Base2(){ std::cout << __PRETTY_FUNCTION__ << std::endl; std::uintptr_t t =3D (std::uintptr_t)&aligned2; printf("%lx\n", (long)(t&0xff)); } virtual ~Base2(){ std::uintptr_t t =3D (std::uintptr_t)&aligned2; printf("%lx\n", (long)(t&0xff)); 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; } Looks like there is some wrong alignment information feed to the rest of the compiler. this->9ICategoryI5Base2E:b8 this->9ICategoryI5Base1E:c0=