[Cfp-interest 2588] more about N3071

Jim Thomas jaswthomas at sbcglobal.net
Wed Jan 4 20:03:53 PST 2023


Responses below represent conclusions of CFP discussion about the questions posed in N3071.

The essence of the C++ constexpr seems (based on information on the internet) to be that the initialization can (but does not have to) be done at translations time. The responses below assume C wants a level of compatibility with C++. The responses take as given the C constraint in 6.7.1 #5 that says initialization can not include a change in value (though it seems off target for the essential meaning in C++). In this context, the responses seek to clarify the cases Joseph provided, particularly cross-radix and cross-type domain initializations, for reasonable floating-point semantics. 

Question 1 (real to complex). Suggest no constraint violation. x1 gets CMPLX(1.0, 0.0). The conversion entails no value change. This allows convenient initialization of complex with real, like initializing floating with integer.
The same applies to imaginary to complex.

Question 2 (complex to real). Suggest constraint violation. The conversion entails no value change, but the imaginary component is lost. There’s no convenience factor here. The same applies to complex to imaginary.

Question 3 (complex to real). Same as Question 2.

Question 4 (quiet NaNs).  Suggest no constraint violation. All results are a quiet NaN. Treatment of payloads is left to the implementation (as almost always). Payloads are considered extra information, but not part of the values.

Question 5 (signaling NaNs). Suggest constraint violation in all the cases, because the signaling NaN value is (or may be) changed. In the last two cases when double and long double have the same format, the constraint violation wouldn’t be necessary if all conversions between double and long double would be done by copy, but singling out that case to be valid seems unduly complicated and not portable. Note that same-type initialization with SNAN macros should not be a constraint violation because the result is required to be a signaling NaN.

Question 6 (standard, binary or integer to decimal). Suggest no constraint violation for any of the examples.

Question 7 (decimal to standard or binary). Suggest constraint violation. The quantum is lost in the first two. The second two could be allowed (no quantum is lost) but that seems like an extra complication for no value.

Question 8 (quantum exponents). Suggest constraint violation. The quantum exponent is part of the value.

Other approaches to constexpr:

1. Allow the initialization only if it is independent of the state of the floating-point environment.

2. Require the initializer to be an arithmetic constant expression and evaluate it at translation time, without regard for value changes or potential changes in the dynamic floating-point environment.

- Jim Thomas


> On Dec 30, 2022, at 10:30 AM, Joseph Myers <joseph at codesourcery.com> wrote:
> 
> I would like to draw the CFP group's attention to comment GB-081 and the 
> associated document N3071 (Conversions in constexpr initializers), as a 
> floating-point issue where the call for CFP recommendations is found in 
> the document N3071 rather than the comment itself.  It would probably be 
> helpful if the CFP group could consider N3071 at their meeting and produce 
> recommendations for the answers to the questions therein, saying which 
> exactly of the cases in the examples should be valid, and associated 
> wording to implement those answers in normative text.
> 
> -- 
> Joseph S. Myers
> joseph at codesourcery.com

_______________________________________________
Cfp-interest mailing list
Cfp-interest at oakapple.net
http://mailman.oakapple.net/mailman/listinfo/cfp-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20230104/334c40e6/attachment-0001.htm>


More information about the Cfp-interest mailing list