public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Joseph Myers <joseph@codesourcery.com>,
	 Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: C PATCH to rectify warning for character types (PR c/23087)
Date: Fri, 08 Jan 2016 17:49:00 -0000	[thread overview]
Message-ID: <568FF69B.10803@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1601072117140.31194@digraph.polyomino.org.uk>

On 01/07/2016 02:19 PM, Joseph Myers wrote:
> On Thu, 7 Jan 2016, Marek Polacek wrote:
>
>> This PR points out that we issue a wrong warning message when assigning
>> two pointers when one of them is plain char.  In that case, the compiler
>> currently says that pointer targets differ in signedness.  But that is
>> not correct; char is a separate type from (un)signed char and is not
>> compatible with either.  So we should instead say that the pointer types
>> are not compatible.
>>
>> This effectively means that I'm turning a -Wpointer-sign warning into
>> a -Wincompatible-pointer-types warning.  But -Wincompatible-pointer-types
>> is a warning that is enabled by default and -Wpointer-sign is enabled by
>> -Wpedantic || -Wall.  So with this, we'd be more verbose and would warn
>> by default on e.g. "unsigned char *p = "foo";."  Not sure if that is
>> desirable at this stage, so I'm leaning towards pushing this patch for
>> GCC7.
>
> I don't think it's desirable to raise the warning for this case under
> different conditions from the warning for other signedness cases.  The
> targets do differ in signedness - it's just that the difference is between
> "plain" and "signed" or "plain" and "unsigned", not between signed and
> unsigned.

I'm sorry Joseph but I don't quite follow this argument.  Plain
char is neither a signed [integer] type nor an unsigned [integer]
type, so it can never differ in signedness from any other type.

It seems to me that by the interpretation you suggest, converting
a signed int* to unsigned long* should be controlled by -Wpointer-
sign when int and long have the same representation, and by
-Wincompatible-pointer-types otherwise.  (Which is not what GCC
does.)

In my view, Marek's change makes perfect sense because it the most
closely reflects the properties of the type.

Martin

  reply	other threads:[~2016-01-08 17:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 17:11 Marek Polacek
2016-01-07 21:19 ` Joseph Myers
2016-01-08 17:49   ` Martin Sebor [this message]
2016-01-08 22:27     ` Joseph Myers
2016-01-08 23:28       ` Martin Sebor
2016-01-08 23:51         ` Joseph Myers
2016-01-09  1:21           ` Martin Sebor
2016-01-11 16:37             ` Martin Sebor
2016-01-08 17:54   ` Bernd Schmidt
2016-01-08 18:07     ` Marek Polacek

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=568FF69B.10803@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --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).