[Bug c++/11492] New: Unsigned char promoted to signed int in for loop test for gpp but not gcc

afonso at contronics dot com dot br gcc-bugzilla@gcc.gnu.org
Thu Jul 10 19:28:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11492

           Summary: Unsigned char promoted to signed int in for loop test
                    for gpp but not gcc
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: afonso at contronics dot com dot br
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i586-pc-msdosdjgpp
  GCC host triplet: i586-pc-msdosdjgpp
GCC target triplet: i586-pc-msdosdjgpp

The following program ( no includes ) generates a compiler warning, even though 
it should not:

int main( void ) {

    unsigned int a;
    unsigned char b;

 
    for ( a = 0, b = 2; a > b * 1000; a++ ) {
    }

    return 0;

}


This program creates a warning when compiled using the command line:

gpp -Wall volatile.c -o volatile

No warning is given when the following command line is used:

gcc -Wall volatile.c -o volatile


The compiler warning given is as follows:

volatile.c: In function `int main()':
volatile.c:7: warning: comparison between signed and unsigned integer
   expressions


This is strange since every variable used in this program is unsigned. It 
appears that the unsigned char is being promoted to signed int instead of 
unsigned int. gcc and gpp disagree as to whether this is ok. They can't both be 
right.

Here is the output of gpp --verbose

Reading specs from d:/djgpp/lib/gcc-lib/djgpp/3.22/specs
Configured with: /devel/gnu/gcc/3.2/gnu/gcc-3.22/configure i586-pc-msdosdjgpp --
prefix=/dev/env/DJDIR --disable-nls
Thread model: single
gcc version 3.2.2

I am running this on a Windows XP Professional system. gcc was downloaded in 
binary form.



More information about the Gcc-bugs mailing list