C PATCH to rectify warning for character types (PR c/23087)

Joseph Myers joseph@codesourcery.com
Thu Jan 7 21:19:00 GMT 2016


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.  Maybe the warning message should be more specific in this case, 
but not a less-specific "incompatible" which is what this patch would 
achieve.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list