bad C code or bad object code ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



we noticed that xterm in Gentoo started to produce broken color display when 
compiled with gcc-4.1 and -Os ... one of our devs ripped apart a small test 
case to illustrate the issue at hand (Debian shows the same issues)

the trouble centers around a matrix declared as static volatile and is never 
initialized ... xterm expects the matrix to be zero set already, but when 
compiled with -Os, this just doesnt work

example code attached ... to reproduce on an x86 host:
gcc -Os badcode.c
or on an amd64 host, just add -m32
-mike

Attachment: pgpmqJ9JML48x.pgp
Description: PGP signature

#include <stdio.h>
int main() {
	static volatile char s[256][3]; /* default-initialised to 0 */
	int i;

	for(i = 0; i < 256; i++) {
		if(i >= 16 && i < 256)
			printf("%d ", s[i - 16][0]);
	}
	printf("\n");
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux