SUN C compiler bug?

Hiroshi Tachibana tachi at koudai.uucp
Mon Mar 31 06:02:29 AEST 1986


In article <5418 at sri-spam.ARPA> argv at sri-spam.UUCP writes:
> 
>     char x;
>     for(x = 0; x < 128; x++)
> 	putchar('x');
> 
> You would expect to have 128 x's printed on your screen.  but,
> on the sun, the variable x is signed and NOT converted to an int
> as it is on the vax version of the 4.2 UNIX C compiler.

I know a similar bug(?) on the Sun C compiler.
Consider the code something like:

	printf("%d\n", (any_expr, 257)) ;
		/*
		 * Of course, it does not mean printf("%d\n", any_expr, 257) ;
		 * (any_expr, 257) is a comma expression
		 */

This should generate output '257' (it is on Vax), but it actually outputs
'1' on any version of Sun as long as I know (release 1.2, 2.2, 3.0).
It interpretes the last component of comma expression as a singed character,
if it is an integer constant.  This is a bug, isn't it?

----
Hiroshi Tachibana
Dept. of C.S., Tokyo Institute of Technology
UUCP: ...!{hplabs,seismo,ihnp4}!kddlab!koudai!tachi



More information about the Comp.lang.c mailing list