SUN C compiler bug?
Pete Zakel
pete at valid.UUCP
Sat Apr 5 09:20:32 AEST 1986
> 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
I tried this with our C compiler, and it works the way Hiroshi describes. I
assume it is a problem with any PCC based C compiler. Comments, anyone?
(Oh, and I assume you mean "signed" character, as that is the way mine
treated it. When I changed the value from 257 to 254, the program output
'-2' - which, when you think about it, is pretty much of a 'burn', isn't it?
By the way, I got the program to give correct results by changing "257" to
"(unsigned) 257")
--
-Pete Zakel (..!{hplabs,amd,pyramid,ihnp4}!pesnta!valid!pete)
More information about the Comp.lang.c
mailing list