quotes inside #if 0

News system news at ism780c.isc.com
Fri Sep 8 07:59:45 AEST 1989


In article <10969 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>A lot of people say "the Standard broke [whatever]".  The proposed
>Standard breaks nothing.  Standard-conforming C implementations may
>well not produce the same results as others have been producing, but
>there has always been that degree of variation among C compilers.

Here is an example of *well defined* code that produces different results:

    Main()
    {
      unsigned char c=1;
      if (c-2>0) <true-part> else <false-part>

The 'usual conversion rules' in K&R requires that the expression c-2 is
unsigned and therfore the <true-part> executes.  The ANSI 'usual conversion
rules' requires that the expression c-2 be signed and therefore the <false-
part> executes.  This change and other similar ones are called 'quiet changes'

These are direct quotes from the Rationale:

       "a string of the form "\078" is valid, but now has a different
       meaning"

       "A string of the form "\a" or "\x" now has a different meaning"

       "A program that depends upon unsigned preserving arithmetic
       conversions will behave differently, probably without complaint.
       This is considered the most serious semantic change made by the
       Committee to a wide spread current practice".

The standard has clarified the semantics of many cases where different
compilers produced different results.  But it also changed the semantics of
several cases where there was no ambiguity in the base document (K&R).  The
standard does indeed 'break' things.

The only way I can read Doug's assertion (such that it is true) is to say:
since there was no standard for C before THE standard, no programs had
a well defined behavior so nothing got broken.

    Marv Rubinstein

PS: I have heard that Unix release 5.4 uses two compilers.  One to compile
Unix and one (ANSII) for new programs.  Does any one know if this is true?



More information about the Comp.lang.c mailing list