This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFD: C pointer conversions that differ in unsignedness


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.


Attachment: unsignedness.diffs.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]