C compiler bug (I think). [Contains fix <- NOT QUITE]

root at ur-valhalla.UUCP root at ur-valhalla.UUCP
Tue Aug 28 06:57:42 AEST 1984


Well, I've installed Donn Seeley's fix for the C compiler screwing up on
initializing shifted, unsigned variables, and found out a nasty side effect:
The (unsigned) cast is IGNORED!  This is my program:

	main()                          
	{       int big_number = ((~((unsigned) 0)) >> 1);
		printf("this is a big number: %d\n",big_number);
	}                               

Before installing the fix the program produced this output:

	this is a big number: 2147483647

(To remind the original problem: should big_number be declared as static or
as a global variable, C compiler would blow up and go into a loop).
After installing the fix, I got the following output:

	this is a big number: -1

Sigh.... 
-- 
Krzysztof Kozminski (truly sorry for not being able to fix the problem myself)
{seismo,allegra,decvax}!rochester!ur-valhalla!kris



More information about the Comp.lang.c mailing list