egcs-1.0.3 pre-release: unsigned comparisom with 0

Andrew Chittenden WVdevmt-WS achitten@dev.madge.com
Wed May 13 00:16:00 GMT 1998


When an unsigned integer is compared with <= 0, no warning is generated.
Compile time flags include -Wall -W. Attached is a cut down example
of a program that demonstrates the problem.

--- cut here

#include <stdio.h>

unsigned int bigger = 0x26467b5;
unsigned int smaller = 0x26464f5;

int
f(unsigned int p_smaller, unsigned int p_bigger)
{
    int skip = p_smaller - p_bigger;
    if ((p_smaller - p_bigger) <= 0) {
        printf("smaller %d\n", skip);
    } else {
        printf("bigger %d\n", skip);
    }
    if (p_smaller <= 0) {
        printf("smaller is -ve\n");
    } else {
        printf("smaller is +ve\n");
    }
    return skip;
}

int
main()
{
    return f(smaller, bigger);
}

--- cut here
-- 
Rgds, Andy Chittenden

Email:	achitten@madge.com	Fax:	+44 1753 661011
Multimedia Development, Madge Networks Ltd
Wexham Springs, Framewood Road, Wexham, Slough SL3 6PJ, England



More information about the Gcc-bugs mailing list