[Cfp-interest 2574] about N3071

Jim Thomas jaswthomas at sbcglobal.net
Mon Jan 2 12:42:52 PST 2023


Below are my thoughts about the questions posed in N3071. CFP will discuss the questions at its Jan 4 meeting.

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 (sort of) regards the real axis as part of the complex plane. 
Alternatively, we could require the initializer to have the same type domain as the variable. But there seems no harm in allowing the convenience of initializing complex with real, like initializing floating with integer.
The same applies to complex = imaginary.

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 imaginary = complex. It seems unduly complicated to try to allow some complex to real conversions (as regarding the real axis to be a part of the complex plane might suggest), but not others.

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

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 cases. 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 that seems unduly complicated and not portable.

Question 6 (standard, binary or integer to decimal). Suggest no constraint violation for any of the examples. Alternatively, we could require the initializer and the variable types to both be decimal if either is, which would be simple and cover Question 7 too.

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.

- 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20230102/6a35366e/attachment.htm>


More information about the Cfp-interest mailing list