In case of FLT_HAS_SUBNORM == 0
(or any XXX_HAS_SUBNORM == 0
in general) does execution of fpclassify
macro with manually constructed subnormal (constructed using type punning via union
, using memcpy
, reading from file, etc.) lead to undefined behavior (UB) or lead to well-defined behavior (WDB) returning FP_SUBNORMAL
(as expected)?
Notes:
- The C standard is quite restrained about
FLT_HAS_SUBNORM is 0
case. All that is says aboutFLT_HAS_SUBNORM is 0
is:
Characterization as absent is intended if no floating-point operations produce subnormal results from non-subnormal inputs, even if the type format includes representations of subnormal numbers.
which can be interpreted as:
If FLT_HAS_SUBNORM is 0, then any_normal <op> any_normal never produces subnormal.
- The C standard seems to omit explicit definition of behavior for the following case (formulated as a question):
In case if
FLT_HAS_SUBNORM is 0
: does execution of any FP operation with inputs represented by manually constructed subnormals (constructed using type punning viaunion
, usingmemcpy
, reading from file, etc.) lead to undefined behavior (UB)?
- If the explicit definition of behavior is omitted, then according to the C standard:
… Undefined behavior is otherwise indicated in this document… by the omission of any explicit definition of behavior…
UPD20210825: Answer from the committee:
It is FP_ZERO.
Consequences:
- In case of
FLT_HAS_SUBNORM is 0
shall the implementation have DAZ (Denormals Are Zero) property set to 1? Yes. - Shall DAZ=1 be applied to all the operations involving FP numbers (objects)? In progress...