A simple non-portable expression tha

ARPA at brl-smoke ARPA at brl-smoke
Mon Apr 28 19:42:00 AEST 1986


Re:	Long + (Int1 + Int2)

This really does call for Int1 and Int2 to be added first, without
widening to (long), then the sum widened and added to Long.  You
have to watch out when trying to test this on a system where
sizeof(int)==sizeof(long), though: the "integral widening conventions"
will cause (short)s to be widened to (int) before adding if you're
trying to test this by making Int1 and Int2 (short)s.

The Ritchie PDP-11 C compiler does correctly distinguish between
	Long + (Int1 + Int2)
and
	Long + Int1 + Int2
which result in different machine instruction sequences.

An additional note:  I've had a lot of trouble with code semantics
getting screwed up by PCC's derived from Berkeley's (which in turn
seems to have been borrowed from USG 3.0).  Types don't propagate
correctly in expressions, casts are ignored, etc.  A real mess.
I tried using the 4.2BSD PCC to generate code for my UNIX System V
emulation, but finally out of disgust adapted the SVR2 PCC instead.
I know Donn Seeley has been working on the Berkeley PCC, so perhaps
the 4.3BSD version will be better.  Why Berkeley insists on not
using any AT&T software released after 1979 I don't know; their
"licensing" argument doesn't hold water.  I would urge all UNIX
system vendors to start with SGS2/PCC2, or at least the latest AT&T
"old PCC", rather than the 4.2BSD PCC that some seem to have used.



More information about the Comp.lang.c mailing list