Unformatted version of **ai05s/ai05-0088-1.txt version 1.3**

Other versions for file**ai05s/ai05-0088-1.txt**

Other versions for file

!standard 4.5.6(11) 08-01-30 AI05-0088-1/01

!class binding interpretation 08-01-30

!status WG9 Approved 08-06-20

!status ARG Approved 8-0-1 08-02-10

!status work item 08-01-30

!status received 08-01-25

!priority Low

!difficulty Medium

!qualifier Omission

!subject Only the value of "**" is equivalent to repeated "*"s

!class binding interpretation 08-01-30

!status WG9 Approved 08-06-20

!status ARG Approved 8-0-1 08-02-10

!status work item 08-01-30

!status received 08-01-25

!priority Low

!difficulty Medium

!qualifier Omission

!subject Only the value of "**" is equivalent to repeated "*"s

!summary

The equivalence in 4.5.6(11) only means that the value (and its accuracy) is
equivalent, not that any side-effects of such an expansion need be done.

!question

4.5.6(11) says:

The right operand of an exponentiation is the exponent. The expression
X**N with the value of the exponent N positive is equivalent to the expressions
X*X*...X (with N-1 multiplications) except that the multiplications are
associated in an arbitrary order.

If X is a volatile or atomic variable, is the implementation required to
read it N times? (No.)

If X is a function call with side effects, is the implementation required to
call the function N times? (No.)

!recommendation

!wording

Change 4.5.6(11) as follows:

The right operand of an exponentiation is the exponent. The {value of}
[expression] X**N with the value of N positive is [equivalent to the expressions]
{the same as the value of} X*X*...X (with N-1 multiplications) except that
the multiplications are associated in an arbitrary order. ...

!discussion

This is just another case where "equivalent" really means "the same, other than
when they are different".

!corrigendum 4.5.6(11)

Replace the paragraph:

The right operand of an exponentiation is the *exponent*. The expression X**N
with the value of the exponent N positive is equivalent to the expression
X*X*...X (with N–1 multiplications) except that the multiplications are
associated in an arbitrary order. With N equal to zero, the result is one.
With the value of N negative (only defined for a floating point operand),
the result is the reciprocal of the result using the absolute value of N
as the exponent.

by:

The right operand of an exponentiation is the *exponent*. The value of X**N
with the value of the exponent N positive is the same as the value of
X*X*...X (with N–1 multiplications) except that the multiplications are
associated in an arbitrary order. With N equal to zero, the result is one.
With the value of N negative (only defined for a floating point operand),
the result is the reciprocal of the result using the absolute value of N
as the exponent.

!ACATS Test

None is needed for this; hopefully no one is depending on these sorts of side effects.

!appendix

From: Robert A. Duff Sent: Friday, January 25, 2008 7:06 PM Here's an entertaining question Robert Dewar came up with. Suppose we say X**N, where N is positive. RM-4.5.6 says: 11 {exponent} The right operand of an exponentiation is the exponent. The expression X**N with the value of the exponent N positive is equivalent to the expression X*X*...X (with N-1 multiplications) except that the multiplications are associated in an arbitrary order. If X is a volatile or atomic variable, is the implementation required to read it N times? (No!) And Gary Dismukes piled on with this follow-on question: If X is a function call with side effects, is the implementation required to call the function N times? (No!) I guess this is another one of those cases where "equivalent" really means "the same, only different". Clearly X should be evaluated exactly once (and read exactly once if volatile). Same for N. How about: 11 {exponent} The right operand of an exponentiation is the exponent. The value of X**N with N positive is the same as the value of X*X*...X (with N-1 multiplications) except that the multiplications are associated in an arbitrary order. ? And I presume it's safe to assume we're talking about the predefined "**", here -- user-defined "**" is not "equivalent" to N "*" ops! ****************************************************************

Questions? Ask the ACAA Technical Agent