Any level of optimization will ignore integer promotion rules, which say ( I'm paraphrasing )that when using comparison( == ) any integer with a rank lower than int will get promoted to int if it can represent all values (C Standard 2011: 6.3.1.1) .
No printf() should be reachable in the code.
#include <stdio.h>
int main( void )
{
signed char a = -1;
unsigned char b = a;
if( b == a ) //both promoted to int, result is 255 == -1, which yields false
printf("unreachable\n") ;
if( b == -1 )
printf("unreachable\n") ;
if( ( unsigned char )a == a )
printf("unreachable\n") ;
if( ( int )b == ( int )-1 ) //even if explicitly cast to int
printf("unreachable\n") ;
short sa = -1;
unsigned short sb = sa;
if( sb == sa )
printf("unreachable\n") ;
if( sb == -1 )
printf("unreachable\n") ;
if( ( unsigned short )sa == sa )
printf("unreachable\n") ;
return 0;
}
I'm using version 8.00.11 RC#4, 32bit , Windows 7