This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
unexpected warning "comparison of promoted ~unsigned with unsigned warning"
- From: Pedro Pedruzzi <pedro dot pedruzzi at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 06 Mar 2012 10:41:26 -0300
- Subject: unexpected warning "comparison of promoted ~unsigned with unsigned warning"
- Authentication-results: mr.google.com; spf=pass (google.com: domain of pedro.pedruzzi@gmail.com designates 10.236.189.98 as permitted sender) smtp.mail=pedro.pedruzzi@gmail.com; dkim=pass header.i=pedro.pedruzzi@gmail.com
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