public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-103303-4-I62bJCJpKw@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103303-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103303 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- #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::uintptr_t t = (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 = (std::uintptr_t)&aligned1; printf("%lx\n", (long)(t&0xff)); } virtual ~Base1(){ std::uintptr_t t = (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 = (std::uintptr_t)&aligned2; printf("%lx\n", (long)(t&0xff)); } virtual ~Base2(){ std::uintptr_t t = (std::uintptr_t)&aligned2; printf("%lx\n", (long)(t&0xff)); 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; } Looks like there is some wrong alignment information feed to the rest of the compiler. this->9ICategoryI5Base2E:b8 this->9ICategoryI5Base1E:c0
next prev parent reply other threads:[~2021-11-17 22:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-17 15:30 [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 wqpfelix at gmail dot com 2021-11-17 22:06 ` pinskia at gcc dot gnu.org [this message] 2021-11-18 7:51 ` [Bug c++/103303] compiler have trouble to point to the correct destructor address while for large align objects with complex inheritance while destructing object rguenth at gcc dot gnu.org 2021-11-26 14:36 ` wqpfelix at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103303-4-I62bJCJpKw@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).