This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: /internet
- To: moshier at mediaone dot net
- Subject: Re: /internet
- From: Joe Buck <jbuck at Synopsys dot COM>
- Date: Wed, 16 Dec 98 11:58:08 PST
- Cc: jbuck at Synopsys dot COM, tim at wagner dot Princeton dot EDU, law at cygnus dot com, tprince at cat dot e-mail dot com, bosch at gnat dot com, burley at gnu dot org, egcs at cygnus dot com, hjstein at bfr dot co dot il
> > Does IEEE require left-to-right evaluation of y = a * b * c * d;
> > when there are no parentheses present?
>
> I think that IEEE does not actually say anything about it. C9X, however,
> does contain some remarks such as the following, which might have come
> from NCEG.
> int a, b;
> /* ... */
> a = a + 32760 + b + 5;
>
> the expression statement behaves exactly the same as
>
> a = (((a + 32760) + b) + 5);
>
> due to the associativity and precedence of these operators.
> Thus, the result of the sum (a + 32760) is next added to b,
> and that result is then added to 5 which results in the
> value assigned to a. On a machine in which overflows
> produce an explicit trap and in which the range of values
> representable by an int is [-32768, +32767], the
> implementation cannot rewrite this expression as
>
> a = ((a + b) + 32765);
Amazing. These guys are trying to turn C into Ada.
If this is the rule, then a*b*c*d can't be rearranged in C9X. However,
it appears that it can be rearranged in Fortran (where the user must
use parentheses to force the order of evaluation) as well as in the
current ANSI/ISO C.