Document: WG14 N1382

FLT_EVAL_METHOD and return

Submitter: Fred Tydeman and Jim Thomas (USA)
Submission Date: 2009-04-02
Previous version of paper: N1353
Related WG14 documents: N1321, DR 290
Subject: FLT_EVAL_METHOD and return

This paper notes a problem related to the following sections of text, in C1x draft N1362, as recently modified by N1321, and proposes a way to fix it. #3

If a return statement with an expression is executed, the value of the expression is returned to the caller as the value of the function call expression. If the expression has a type different from the return type of the function in which it appears, the value is converted as if by assignment to an object having the return type of the function.142)

142) The return statement is not an assignment. The overlap restriction of subclause does not apply to the case of function return. The representation of floating-point values may have wider range or precision and is determined by FLT_EVAL_METHOD. A cast may be used to remove this extra range and precision.

Problem: Footnote 142 now implies that function returns are widened by widening expression evaluation methods. This specification is not tenable from an ABI/API perspective because it would introduce inconsistencies between the format expected by the callers and the format returned by the callee, depending on the evaluation method used for their translation.

The following recommended change fixes this.

In footnote 142, remove "and is determined by FLT_EVAL_METHOD"

Words for Rationale:

The value of the floating expression following return is evaluated as per FLT_EVAL_METHOD. However, the ABI or API (not FLT_EVAL_METHOD) determines how that floating value is returned from the function.