[Bug testsuite/39830] New: gcc.dg/torture/pr39678.c fails if char type is unsigned

jingyu at google dot com gcc-bugzilla@gcc.gnu.org
Tue Apr 21 00:41:00 GMT 2009


On gcc.dg/torture/pr39678.c, it assigns -3 to a char variable ("x.c = -3") and
later checks if the char variable equals to -3 ("if (x.c != 3)").

This check would fail if the char type is unsigned.

Suggest to change -3 to 3. This change does not affect the purpose of the test
case.

I have tried this tiny test.
#include <stdio.h>
int main() {
  char ch = -3;
  if (ch != -3) {
    printf ("ch != -3\n");
    return 1;
  }
  return 0;
}

$~/local/gcc_i686/bin/gcc -funsigned-char  testx.c -o testx-2
$./testx-2
ch != -3
$~/local/gcc_i686/bin/gcc -fsigned-char  testx.c -o testx-1
$ ./testx-1
<pass>

$ ~/local/gcc_i686/bin/gcc -vUsing built-in specs.
Target: i686-linux
Configured with: --target=i686-linux --build=i686-linux --host=i686-linux
--enable-languages=c,c++
Thread model: posix
gcc version 4.4.0 20090413 (prerelease) (GCC)

Thanks!


-- 
           Summary: gcc.dg/torture/pr39678.c fails if char type is unsigned
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jingyu at google dot com


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



More information about the Gcc-bugs mailing list