Bug#176387: {sparc} gcc-3.2 regression
Package: gcc-3.2
Version: 2.3.1-9
Severity: important
Distilled from the gpc bootstrap failure on sparc-linux:
#include <stdio.h>
int main ()
{
FILE *s = fopen("foobar","w");
char a[4] = { 0, 0, -1, 0 };
printf ("%i\n", fwrite_unlocked (a, 1, 4, s));
}
$ gcc-2.95 -O2 fbug.c && ./a.out
4
$ gcc-3.0 -O2 fbug.c && ./a.out
4
$ gcc-3.2 -O2 fbug.c && ./a.out
2
$ gcc-3.2 -O1 fbug.c && ./a.out
4
Or a simplified example from the fwrite_unlocked macro definition:
int x = 0;
int main ()
{
char a[4] = { -1 }, *q = a;
int c;
for (c = 2; c > 0; --c)
if ((x ? 0 : (unsigned char) (*q = *a)) == -1)
break;
printf ("%i\n", c);
}
Reply to: