public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/60963] [4.10 Regression] wrong devirt with placement new
Date: Fri, 25 Apr 2014 12:33:00 -0000	[thread overview]
Message-ID: <bug-60963-4-BhOLBI1cgy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60963-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60963

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-25
            Summary|ubsan runtime error: load   |[4.10 Regression] wrong
                   |of null pointer of type     |devirt with placement new
                   |'<unknown> *'               |
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
#include <new>

extern "C" void abort (void);

class EmbeddedObject {
public:
    virtual int val() { return 2; }
};

class Container {
    alignas(EmbeddedObject) char buffer[sizeof(EmbeddedObject)];
public:
    EmbeddedObject *obj() { return (EmbeddedObject*)buffer; }
    Container() { new (buffer) EmbeddedObject(); }
};

Container o;

int main()
{
  if (o.obj()->val() != 2)
    abort ();
}

It's interesting how the gcc_unreachable () makes writing a testcase that
aborts almost impossible (the above doesn't work, nor if I move the call
into a separate non-inlined function ...).


  reply	other threads:[~2014-04-25 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-25 11:31 [Bug sanitizer/60963] New: ubsan runtime error: load of null pointer of type '<unknown> *' redi at gcc dot gnu.org
2014-04-25 12:33 ` rguenth at gcc dot gnu.org [this message]
2014-04-25 12:33 ` [Bug ipa/60963] [4.10 Regression] wrong devirt with placement new rguenth at gcc dot gnu.org
2014-04-25 14:24 ` aph at gcc dot gnu.org

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-60963-4-BhOLBI1cgy@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: link
Be 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).