-Wsign-compare makes gcc complain about bool?unsigned:signed

Martin Str|mberg ams@ludd.luth.se
Sun Mar 17 06:52:00 GMT 2002


gcc --version reports:
3.04

My platform is DJGPP (run in WINDOZE 98).

This program

#include <stdio.h>

int main(void)
{
  unsigned int u;
  int s;
  
  unsigned long long ll = u?u:s;

  printf("ll = %llu.\n", ll);

  return( 0 );

}

compiled with "gcc -O2 -g -Wall c.c -o c -Wsign-compare" gives

c.c: In function `main':
c.c:8: warning: signed and unsigned type in conditional expression
c.c:5: warning: `u' might be used uninitialized in this function
c.c:6: warning: `s' might be used uninitialized in this function

I have no problem with line 5 and 6.

But line 8. Why is that wrong? And why does -Wsign-compare trigger
this warning when it's not a comparison?


Right,

						MartinS



More information about the Gcc-bugs mailing list