ANSIfication: value preserving rules

Doug Gwyn gwyn at brl-smoke.ARPA
Mon Apr 11 09:25:21 AEST 1988


In article <11000 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>In find it significant that the unsigned preserving rules can be stated
>in four words, while the value preserving rules require a paragraph
>full of conditional wording.

Although I did not support the adoption of value-preserving rules
(and AT&T's representatives vociferously opposed it), I feel obliged
to note that you have carefully arranged the argument to put the
best light on your preference.  It takes more than 4 words to express
the complete signedness-preserving rules!  In fact the complete
conversion rules are approximately as difficult to express completely
for either approach.

The following example shows what X3J11 seems to have had in mind when
adopting value-preserving rules (which were based on some subset of
existing practice, by the way):

	unsigned short us = 1;
	int i = us - 2;
	printf("%d\n",i);

which one would think should print "-1", which it does under the
value-preserving rules but not under the signedness-preserving rules.

It has been reported that when AT&T recompiled all the UNIX system
sources with an experimental value-preserving compiler, practically
nothing broke.  My experience has been that mixed-signedness
expressions have tended to be buggy under signedness-preserving rules
and that a change to value-preserving rules would straighten out some
of the bugs I have encountered.

The bottom line is that this is a change we can probably live with.



More information about the Comp.lang.c mailing list