public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: Re: [PATCH] c-family: Update unaligned adress of packed member check
Date: Wed, 16 Jan 2019 12:28:00 -0000	[thread overview]
Message-ID: <20190116122826.GS30353@tucnak> (raw)
In-Reply-To: <CAMe9rOpwJUiAksUKPw77skg03B_3aQKkdxH_fJhc6e5bNXoG-Q@mail.gmail.com>

On Wed, Jan 16, 2019 at 04:11:44AM -0800, H.J. Lu wrote:
> > Why?  What is so special about C and (implicit?) casts where the rhs isn't
> > ADDR_EXPR?  Aren't all casts (explicit or implicit) from one pointer type
> > to another pointer and satisfy the rules something that should be warned
> 
> -Wincompatible-pointer-types is C only.   In C++,  incompatible pointer types
> aren't allowed at all.

How so?  You can certainly:
struct B { int i; };
struct C { struct B b; } __attribute__ ((packed));

extern struct C *p;
long* g8 (void) { return (long *)p; }

and similarly for C.  So, why is explicit cast something that shouldn't
be warned about in this case and implicit cast should get a warning,
especially when it already does get one (and one even enabled by default,
-Wincompatible-pointer-types)?
Either such casts are problematic and then it should treat explicit and
implicit casts the same, or they aren't, and then
-Wincompatible-pointer-types is all you need.

	Jakub

  reply	other threads:[~2019-01-16 12:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-13 12:49 [PATCH] C-family: Only check the non-pointer data member H.J. Lu
2019-01-13 13:20 ` Jakub Jelinek
2019-01-13 14:54   ` H.J. Lu
2019-01-14 14:22     ` Jakub Jelinek
2019-01-14 18:00       ` [PATCH] c-family: Update unaligned adress of packed member check H.J. Lu
2019-01-14 23:23         ` H.J. Lu
2019-01-16 23:09           ` Jakub Jelinek
2019-01-17 14:46             ` H.J. Lu
2019-01-16 11:31         ` Jakub Jelinek
2019-01-16 12:12           ` H.J. Lu
2019-01-16 12:28             ` Jakub Jelinek [this message]
2019-01-17  4:57               ` V2 " H.J. Lu
2019-01-17 12:56                 ` H.J. Lu
2019-01-17 15:36                 ` Jakub Jelinek
2019-01-17 20:27                   ` H.J. Lu
2019-01-18  0:01                     ` V3 " H.J. Lu
2019-01-18 11:10                       ` Jakub Jelinek
2019-01-21 12:57                         ` Maxim Kuvyrkov
2019-01-21 13:00                           ` H.J. Lu

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=20190116122826.GS30353@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=jason@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).