FLT_HAS_SUBNORM is 0: does execution of fpclassify() with manually constructed subnormal lead to UB or lead to WDB returning FP_SUBNORMAL?

Viewed 106

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:

  1. The C standard is quite restrained about FLT_HAS_SUBNORM is 0 case. All that is says about FLT_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.

  1. 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 via union, using memcpy, reading from file, etc.) lead to undefined behavior (UB)?

  1. 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:

  1. In case of FLT_HAS_SUBNORM is 0 shall the implementation have DAZ (Denormals Are Zero) property set to 1? Yes.
  2. Shall DAZ=1 be applied to all the operations involving FP numbers (objects)? In progress...
0 Answers
Related