[Cfp-interest 2140] Freestanding with FP binding - wording

Rajan Bhakta rbhakta at us.ibm.com
Fri Sep 17 08:43:24 PDT 2021




Here are some words for both alternatives listed in CFP 2085 (attached)
below.
Note that the words for alternative (1) can be further specified in terms
of actual changes to all the specification for the contents of the headers
that we now allow in fenv.h and math.h and stdlib,h, but I think that would
reduce clarity and be more fragile and prone to error. Hence a minimal
change is proposed alone.


For alternative (1), in N2596, change Section 4#7 from:

The strictly conforming programs that shall be accepted by a conforming
freestanding implementation that defines __STDC_IEC_60559_BFP__ or
__STDC_IEC_60559_DFP__ may also use features in the contents of the
standard headers <fenv.h> and <math.h> and the numeric conversion functions
(7.22.1) of the standard header <stdlib.h>. All identifiers that are
reserved when <stdlib.h> is included in a hosted implementation are
reserved when it is included in a freestanding implementation.

to:

The strictly conforming programs that shall be accepted by a conforming
freestanding implementation that defines __STDC_IEC_60559_BFP__ or
__STDC_IEC_60559_DFP__ may also use features in the contents of the
standard headers <fenv.h> and <math.h> and the numeric conversion functions
(7.22.1) of the standard header <stdlib.h>
  without the requirements to set errno (see 7.5), or modify the floating
point environment (see 7.6)
. All identifiers that are reserved when <stdlib.h> is included in a hosted
implementation are reserved when it is included in a freestanding
implementation.


For alternative (2), in N2596, change 7.22.1.5#10 (and similar changes for
the rest of the family of functions) from:

The functions return the converted value, if any. If no conversion could be
performed, zero is returned. If the correct value overflows and default
rounding is in effect (7.12.1), plus or minus HUGE_VAL, HUGE_VALF, or
HUGE_VALL is returned (according to the return type and sign of the value),
and the value of the macro ERANGE is stored in errno. If the result
underflows (7.12.1), the functions return a value whose magnitude is no
greater than the smallest normalized positive number in the return type;
whether errno acquires the value ERANGE is implementation-defined.

to:

The functions return the converted value, if any. If no conversion could be
performed, zero is returned. If the correct value overflows and default
rounding is in effect (7.12.1), plus or minus HUGE_VAL, HUGE_VALF, or
HUGE_VALL is returned (according to the return type and sign of the value),
and the value of the macro ERANGE is stored in errno
  if the integer expression math_errhandling & MATH_ERRNO is nonzero. If
the integer expression math_errhandling & MATH_ERREXCEPT is nonzero, the
"overflow" floating-point exception is raised.
 If the result underflows (7.12.1), the functions return a value whose
magnitude is no greater than the smallest normalized positive number in the
return type; whether errno acquires the value ERANGE
  if the integer expression math_errhandling & MATH_ERRNO is nonzero is
implementation defined. If the integer expression math_errhandling &
MATH_ERREXCEPT is nonzero, whether the "underflow" floating-point exception
is raised
is implementation-defined.

Regards,

Rajan Bhakta
z/OS XL C/C++ Compiler Technical Architect
ISO C Standards Representative (Canada, USA), PL22.11 Chair
C/C++ Compiler Development
rbhakta at us.ibm.com

IBM



From:	"Rajan Bhakta" <rbhakta at us.ibm.com>
To:	cfp-interest at oakapple.net
Date:	08/05/2021 02:19 PM
Subject:	[EXTERNAL] [Cfp-interest 2085] Freestanding with FP binding
Sent by:	"Cfp-interest" <cfp-interest-bounces at oakapple.net>



Looking at the specification, I think the only thing that really works is
to do something like the following: 1) Say for freestanding that error
conditions do not necessarily have to be handled (including setting errno).
This would have the ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd


Looking at the specification, I think the only thing that really works is
to do something like the following:
1) Say for freestanding that error conditions do not necessarily have to be
handled (including setting errno). This would have the new side effect of
not requiring using exceptions as well.
or
2) Change the strtod family of functions to allow exceptions to be used for
error reporting instead of just errno. This would be a change to the
general C standard, but likely more palatable.

With regards to the whitespace and decimal point scanning, as long as we
allow a freestanding implementation to have just the C locale (as it is
now) and a single fixed code page, I think it would work for freestanding.
The issues described in WG14 19444 still apply however meaning the code is
not necessarily portable, but this may be something we either accept, or
mandate that the C locale must be used.

Regards,

Rajan Bhakta
z/OS XL C/C++ Compiler Technical Architect
ISO C Standards Representative (Canada, USA), PL22.11 Chair
C/C++ Compiler Development
rbhakta at us.ibm.com

IBM
_______________________________________________
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/20210917/aaf8c5d8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20210917/aaf8c5d8/attachment.gif>


More information about the Cfp-interest mailing list