public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Joseph Myers <joseph@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Nathan Sidwell	<nathan@acm.org>, Jason Merrill <jason@redhat.com>,
	Marek Polacek	<polacek@redhat.com>
Subject: Re: [PATCH] Add a -Wcast-align=strict warning
Date: Wed, 13 Sep 2017 19:52:00 -0000	[thread overview]
Message-ID: <AM5PR0701MB26579114FABD8F8F4D2CEB2CE46E0@AM5PR0701MB2657.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1709131701160.29579@digraph.polyomino.org.uk>

On 09/13/17 19:06, Joseph Myers wrote:
> What does this warning do in cases where a type has different alignments
> inside and outside structs?  I'm thinking of something like
> 
> struct s { long long x; } *p;
> /* ... */
> (long long *)p
> 
> on 32-bit x86 - where long long's preferred alignment is 8 bytes, but in
> structures it's 4 bytes.  (Likewise for double in place of long long.)  I
> think a warning for a (long long *)p cast might be surprising in that
> case.
> 

Well, yes this does get a warning.  But doesn't that cast then violate
the underlying alignment requirement of long long* ?

Of course there is probably a reason why -Wcast-align is not enabled by
default, and likewise this warning emits a fair amount of false
positives, but nevertheless I think it is often worth looking at the
places where this warning flags a possible alignment issue.

However, neither -Wcast-align nor -Wcast-align=strict are enabled unless
explicitly requested.


Bernd.

  reply	other threads:[~2017-09-13 19:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-04  8:07 Bernd Edlinger
2017-09-11 13:53 ` [PING] " Bernd Edlinger
2017-09-13 17:06 ` Joseph Myers
2017-09-13 19:52   ` Bernd Edlinger [this message]
2017-09-13 20:03     ` Joseph Myers
2017-09-13 20:55       ` Bernd Edlinger
2017-09-13 20:57         ` Joseph Myers
2017-09-14 16:33 ` [PATCHv2] " Bernd Edlinger
2017-09-15 15:51   ` Joseph Myers

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=AM5PR0701MB26579114FABD8F8F4D2CEB2CE46E0@AM5PR0701MB2657.eurprd07.prod.outlook.com \
    --to=bernd.edlinger@hotmail.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=nathan@acm.org \
    --cc=polacek@redhat.com \
    /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).