unexpected warning "comparison of promoted ~unsigned with unsigned warning"

Pedro Pedruzzi pedro.pedruzzi@gmail.com
Tue Mar 6 13:41:00 GMT 2012


Hello,

Consider the following test C function:

int f(void)
{
	volatile struct {
		unsigned char a;
		unsigned char b;
	} s;

	s.a = 0xbc;
	s.b = s.a ^ 0xff;

	return s.a != (s.b ^ 0xff);
}

When compiled by gcc 4.6.1 with:

gcc -c wpromoted-simple.c -Wsign-compare

I'm getting:

wpromoted-simple.c: In function 'f':
wpromoted-simple.c:11:13: warning: comparison of promoted ~unsigned with
unsigned [-Wsign-compare]

This is unexpected to me. Without the volatile, I don't get the warning.

Is this a different effect of bug #38341 ?

Thanks,
-- 
Pedro Pedruzzi



More information about the Gcc mailing list