public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/63179] New: Does not work virtuality @ 2014-09-04 18:46 isak50 at mail dot ru 2014-09-04 21:59 ` [Bug c++/63179] Virtuality is not working redi at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: isak50 at mail dot ru @ 2014-09-04 18:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63179 Bug ID: 63179 Summary: Does not work virtuality Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: isak50 at mail dot ru // g++ 1.cpp -O2 -Wall -std=c++11 -Wall #include <stdio.h> struct Base{ virtual void f() {printf("base\n");} }; struct Child : Base{ void f()override {printf("child\n");} }; alignas(Child) char buf[sizeof(Child)]; union Ptr{ decltype(::buf) buf; Base base; }; int main(){ new(buf) Child; Ptr *ptr = reinterpret_cast<Ptr*>(buf); //-------------------printf: base---// ptr->base.f(); // Base &b = ptr->base; // b.f(); // clang print "child". //----------------------------------// //-------------------printf: child--// Base *b2 = &ptr->base; // b2->f(); // //----------------------------------// } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/63179] Virtuality is not working 2014-09-04 18:46 [Bug c++/63179] New: Does not work virtuality isak50 at mail dot ru @ 2014-09-04 21:59 ` redi at gcc dot gnu.org 2014-09-05 6:52 ` isak50 at mail dot ru 2014-09-05 8:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2014-09-04 21:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63179 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- I don't think this is valid, the standard says it is OK to access the stored value of the Child object through a union that has a Child member, or to access it through Base, but not through a union that has a Base member. So the program has undefined behaviour and any result is valid. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/63179] Virtuality is not working 2014-09-04 18:46 [Bug c++/63179] New: Does not work virtuality isak50 at mail dot ru 2014-09-04 21:59 ` [Bug c++/63179] Virtuality is not working redi at gcc dot gnu.org @ 2014-09-05 6:52 ` isak50 at mail dot ru 2014-09-05 8:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: isak50 at mail dot ru @ 2014-09-05 6:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63179 --- Comment #2 from Pavel <isak50 at mail dot ru> --- Sorry. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/63179] Virtuality is not working 2014-09-04 18:46 [Bug c++/63179] New: Does not work virtuality isak50 at mail dot ru 2014-09-04 21:59 ` [Bug c++/63179] Virtuality is not working redi at gcc dot gnu.org 2014-09-05 6:52 ` isak50 at mail dot ru @ 2014-09-05 8:42 ` rguenth at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2014-09-05 8:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63179 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- . ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-05 8:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-09-04 18:46 [Bug c++/63179] New: Does not work virtuality isak50 at mail dot ru 2014-09-04 21:59 ` [Bug c++/63179] Virtuality is not working redi at gcc dot gnu.org 2014-09-05 6:52 ` isak50 at mail dot ru 2014-09-05 8:42 ` rguenth at gcc dot gnu.org
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).