public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/41874] Incorrect "dereferencing type-punned pointer will break strict-aliasing rules" warning
Date: Fri, 06 Nov 2009 09:16:00 -0000	[thread overview]
Message-ID: <20091106091601.29556.qmail@sourceware.org> (raw)
In-Reply-To: <bug-41874-13604@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from rguenther at suse dot de  2009-11-06 09:16 -------
Subject: Re:  Incorrect "dereferencing type-punned pointer
 will break strict-aliasing rules" warning

On Fri, 6 Nov 2009, pinskia at gcc dot gnu dot org wrote:

> ------- Comment #1 from pinskia at gcc dot gnu dot org  2009-11-06 09:09 -------
> 4.5 also fails and I cannot figure why if I do:

"fails"?

> #include <new>
> struct APInt {
>     int i;
> };
> int main() {
>     APInt I;
>     void *d;
>     char Data[sizeof(APInt)];
>     new((void*)Data)APInt();
>     d = Data;
>     *(APInt*)d = I;
> }
> 
> GCC does not warn.

Of course not - the code is perfectly valid (apart from Data
not having suitable alignment for APInt, but that's unrelated
to aliasing issues).

Richard.


-- 


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


  parent reply	other threads:[~2009-11-06  9:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-30  1:32 [Bug c++/41874] New: " jyasskin at gmail dot com
2009-11-06  9:09 ` [Bug c++/41874] " pinskia at gcc dot gnu dot org
2009-11-06  9:16 ` rguenther at suse dot de [this message]
2009-11-06  9:19 ` pinskia at gcc dot gnu dot org
2009-11-06  9:20 ` rguenth at gcc dot gnu dot org
2010-01-31  9:38 ` fw at deneb dot enyo dot de
2010-01-31 11:18 ` rguenth at gcc dot gnu dot org
     [not found] <bug-41874-4@http.gcc.gnu.org/bugzilla/>
2010-10-05  0:11 ` muravev at yandex dot ru
2010-10-05  4:49 ` fw at gcc dot gnu.org
2010-10-06 19:44 ` muravev at yandex dot ru
2010-10-06 20:57 ` rguenther at suse dot de
2012-10-15  9:27 ` paolo.carlini at oracle dot com
2012-10-15  9:45 ` rguenth at gcc dot gnu.org
2022-01-08 10:49 ` pinskia at gcc dot gnu.org
2022-12-03 22:03 ` jason 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=20091106091601.29556.qmail@sourceware.org \
    --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).