RFD: C pointer conversions that differ in unsignedness

Mike Stump mrs@apple.com
Mon Oct 6 22:41:00 GMT 2003


Code such as:

void f(long *, unsigned long *);

int main()
{
     long *scp;
     unsigned long *ucp;

     ucp = scp;
     scp = ucp;
     f(ucp, scp);
}

is in violation of of the C standard.  We silently accept such code, 
unless -pedantic (or better) is given.  I didn't happen to see this 
listed in extentions.texi.

This was put in:

revision 1.91
date: 1993/05/27 04:30:54;  author: rms;  state: Exp;  lines: +6 -7
(convert_for_assignment): When allowing mixing of
signed and unsigned pointers, compare unsigned types not type sizes.

in c-typeck.c, and before that (going back to 1.1), we always gave at 
least a warning.  In C++, we give the warning.  Other compilers give 
hard errors for these things.

I propose to tighten this up to a warning, unconditionally.  How to 
others feel?  -Wall?  -std=?  Over my dead body?

Apple Radar 2535328.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unsignedness.diffs.txt
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20031006/91846eee/attachment.txt>


More information about the Gcc mailing list