Signed to unsigned comparison

Paul L Schauble PLS at cup.portal.com
Sat Mar 23 15:09:23 AEST 1991


What should a compiler do with the comparison in this example:

    unsigned int a;

    a = 5;
    if (a > -1) ....

Since all of the possible values for a are positive, the comparison 
should always be true and the compiler should process this as though it
were written
    if (1)

Correct? Does the standard address this case?

    ++PLS



More information about the Comp.lang.c mailing list