[Bug c/29725] New: (signed char) to (signed int) typecast missbehaves

stian at nixia dot no gcc-bugzilla@gcc.gnu.org
Sun Nov 5 14:54:00 GMT 2006

The following code-snippest generate wrong numbers with gcc 4.1.1 using -O, -O1
and -O2.

#include <stdio.h>
int main(int arg, char *argv[])
        int j;
        for (j=0; j<256; j++)
                signed char j2=(signed char)j;
                printf("%d\n", (signed int)j2);
        return 0;


           Summary: (signed char) to (signed int) typecast missbehaves
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stian at nixia dot no
 GCC build triplet: i686-pc-linux
  GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux


More information about the Gcc-bugs mailing list