ISO/IEC TS 18661-5:2025
(Main)Programming languages, their environments, and system software interfaces — Floating-point extensions for C — Part 5: Supplementary attributes
Programming languages, their environments, and system software interfaces — Floating-point extensions for C — Part 5: Supplementary attributes
This document specifies extensions to programming language C to include pragmas corresponding to attributes specified and recommended in ISO/IEC 60559 but not supported in ISO/IEC 9899:2024 (also referred to as C23).
Langages de programmation, leurs environnements et interfaces du logiciel système — Extensions à virgule flottante pour C — Partie 5: Attributs supplémentaires
General Information
Relations
Standards Content (Sample)
Technical
Specification
ISO/IEC TS 18661-5
Second edition
Programming languages, their
2025-03
environments, and system software
interfaces — Floating-point
extensions for C —
Part 5:
Supplementary attributes
Langages de programmation, leurs environnements et interfaces
du logiciel système — Extensions à virgule flottante pour C —
Partie 5: Attributs supplémentaires
Reference number
© ISO/IEC 2025
All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may
be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on
the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below
or ISO’s member body in the country of the requester.
ISO copyright office
CP 401 • Ch. de Blandonnet 8
CH-1214 Vernier, Geneva
Phone: +41 22 749 01 11
Email: copyright@iso.org
Website: www.iso.org
Published in Switzerland
© ISO/IEC 2025 – All rights reserved
ii
Contents Page
Foreword .iv
Introduction .v
1 Scope . 1
2 Normative references . 1
3 Terms and definitions . 1
4 Conformance . 1
5 C standard conformance . 2
5.1 Freestanding implementations . .2
5.2 Predefined macros .2
5.3 Standard headers .2
6 Standard pragmas . 2
7 Evaluation formats . 3
7.1 General .3
7.2 Evaluation method pragma .3
7.3 Evaluation method pragma for decimal floating types .4
7.4 Effective evaluation method macros .4
7.5 Evaluation type macros .4
7.6 Evaluation formats for .5
8 Optimization controls . 5
8.1 General .5
8.2 The FP_ALLOW_VALUE_CHANGING_OPTIMIZATION pragma .6
8.3 The FP_ALLOW_ASSOCIATIVE_LAW pragma .6
8.4 The FP_ALLOW_DISTRIBUTIVE_LAW pragma .7
8.5 The FP_ALLOW_MULTIPLY_BY_RECIPROCAL pragma .7
8.6 The FP_ALLOW_ZERO_SUBNORMAL pragma .8
8.7 The FP_ALLOW_CONTRACT_FMA pragma .8
8.8 The FP_ALLOW_CONTRACT_OPERATION_CONVERSION pragma .9
8.9 The FP_ALLOW_CONTRACT pragma .9
9 Reproducibility . 10
9.1 General .10
9.2 The FP_REPRODUCIBLE pragma.10
9.3 Reproducible code .11
10 Alternate exception handling .12
10.1 General . 12
10.2 The FENV_EXCEPT pragma . 13
Bibliography .20
© ISO/IEC 2025 – All rights reserved
iii
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical
Commission) form the specialized system for worldwide standardization. National bodies that are
members of ISO or IEC participate in the development of International Standards through technical
committees established by the respective organization to deal with particular fields of technical activity.
ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations,
governmental and non-governmental, in liaison with ISO and IEC, also take part in the work.
The procedures used to develop this document and those intended for its further maintenance are described
in the ISO/IEC Directives, Part 1. In particular, the different approval criteria needed for the different types
of document should be noted. This document was drafted in accordance with the editorial rules of the ISO/
IEC Directives, Part 2 (see www.iso.org/directives or www.iec.ch/members_experts/refdocs).
ISO and IEC draw attention to the possibility that the implementation of this document may involve the
use of (a) patent(s). ISO and IEC take no position concerning the evidence, validity or applicability of any
claimed patent rights in respect thereof. As of the date of publication of this document, ISO and IEC had not
received notice of (a) patent(s) which may be required to implement this document. However, implementers
are cautioned that this may not represent the latest information, which may be obtained from the patent
database available at www.iso.org/patents and https://patents.iec.ch. ISO and IEC shall not be held
responsible for identifying any or all such patent rights.
Any trade name used in this document is information given for the convenience of users and does not
constitute an endorsement.
For an explanation of the voluntary nature of standards, the meaning of ISO specific terms and expressions
related to conformity assessment, as well as information about ISO's adherence to the World Trade
Organization (WTO) principles in the Technical Barriers to Trade (TBT) see www.iso.org/iso/foreword.html.
In the IEC, see www.iec.ch/understanding-standards.
This document was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology,
Subcommittee SC 22, Programming languages, their environments and system software interfaces.
This second edition cancels and replaces the first edition (ISO/IEC TS 18661-5:2016), which has been
technically revised.
The main changes are as follows:
— The specification has been updated to extend ISO/IEC 9899:2024.
— Conformance macros have been added to allow conformance to each of the four feature sets (evaluation
formats, optimization controls, reproducibility, and alternate exception handling) independently.
A list of all parts in the ISO/IEC 18661 series can be found on the ISO website.
Any feedback or questions on this document should be directed to the user’s national standards
body. A complete listing of these bodies can be found at www.iso.org/members.html and
www.iec.ch/national-committees.
© ISO/IEC 2025 – All rights reserved
iv
Introduction
The IEEE 754-1985 standard for binary floating-point arithmetic was motivated by an expanding diversity
in floating-point data representation and arithmetic, which made writing reliable programs, debugging
and moving programs between systems exceedingly difficult. Now the great majority of systems provide
data formats and arithmetic operations according to IEEE 754. Corresponding versions of IEEE 754 and
ISO/IEC 60559 have equivalent content.
Support for IEEE 754-1985 was added in ISO/IEC 9899:1999 (also referred to as C99), and ISO/IEC 9899:2018
is still based on IEEE 754-1985. However, IEEE 754 underwent a major revision in 2008 and a minor revision
in 2019, which added several new features.
The purpose of the ISO/IEC 18661 series (first published 2014 through 2016) has been to specify C language
support for the new features introduced into IEEE 754 since 1985. Most of the ISO/IEC 18661 series has
been incorporated into ISO/IEC 9899:2024 (also referred to as C23 because major work on this revision was
completed in 2023), which supports all required and most recommended features in IEEE 754-2019.
IEEE 754 defines alternatives for certain attributes of floating-point semantics, and aims to provide, through
programming languages, a means by which a program can specify which of the alternative semantics apply
to a given block of code. The program specification of attributes is constant (fixed at translation time), not
dynamic (changeable at execution time).
The FENV_ROUND and FENV_DEC_ROUND pragmas in C23 provide the rounding direction attributes required by
IEEE 754.
IEEE 754 also recommends other attributes that are not supported in C23, including:
— preferredWidth: evaluation formats for floating-point operations;
— value-changing optimizations: allow/disallow program transformations that can affect floating-point
result values;
— reproducibility: support for getting floating-point result values and exceptions that are exactly
reproducible on other systems;
— alternate exception handling: methods of handling floating-point exceptions.
To supplement the IEEE 754 support in C23, this document provides these recommended attributes by
means of standard pragmas. The pragma parameters represent the alternative semantics. The pragmas are
similar in form to the floating-point pragmas (FENV_ACCESS, FP_CONTRACT, CX_LIMITED_RANGE) that have been
in C since 1999.
© ISO/IEC 2025 – All rights reserved
v
Technical Specification ISO/IEC TS 18661-5:2025(en)
Programming languages, their environments, and system
software interfaces — Floating-point extensions for C —
Part 5:
Supplementary attributes
1 Scope
This document specifies extensions to programming language C to include pragmas corresponding to
attributes specified and recommended in ISO/IEC 60559 but not supported in ISO/IEC 9899:2024 (also
referred to as C23).
2 Normative references
The following documents, in whole or in part, are normatively referenced in this document and are
indispensable for its application. For dated references, only the edition cited applies. For undated references,
the latest edition of the referenced document (including any amendments) applies.
ISO/IEC 9899:2024, Information technology — Programming languages — C
ISO/IEC 60559:2020, Information technology — Microprocessor Systems — Floating-Point arithmetic
3 Terms and definitions
For the purposes of this document, the terms and definitions given in ISO/IEC 9899:2024 and
ISO/IEC 60559:2020 apply.
ISO and IEC maintain terminological databases for use in standardization at the following addresses:
— ISO Online browsing platform: available at https:// www .iso .org/ obp
— IEC Electropedia: available at https:// www .electropedia .org/
4 Conformance
An implementation that meets the requirements for a conforming implementation of C23 may conform to
any or all of the four feature sets in this document. The implementation conforms to the feature sets if
a) it defines __STDC_IEC_60559_BFP__ or __STDC_IEC_60559_DFP__ or both, indicating support for
ISO/IEC 60559 binary or decimal floating-point arithmetic, as specified in C23, Annex F;
and one or more of the following are true:
b) it defines __STDC_IEC_60559_ATTRIB_EVALUATION_FORMAT__ to 202401L and provides the features for
evaluation formats as specified in this document (Clause 7);
c) it defines __STDC_IEC_60559_ATTRIB_OPTIMIZATION__ to 202401L and provides the features for
optimization as specified in this document (Clause 8);
d) it defines __STDC_IEC_60559_ATTRIB_REPRODUCIBLE__ to 202401L and provides the features for
reproducibility as specified in this document (Clause 9);
© ISO/IEC 2025 – All rights reserved
e) it defines __STDC_IEC_60559_ATTRIB_ALTERNATE_EXCEPTION_HANDLING__ to 202401L and provides the
features for alternate exception handling as specified in this document (Clause 10).
5 C standard conformance
5.1 Freestanding implementations
C23, Clause 4 allows freestanding implementations to conform to this document.
5.2 Predefined macros
The implementation defines one or more of the following macros to indicate conformance to the specification
in this document for support of the corresponding attributes specified and recommended in ISO/IEC 60559.
__STDC_IEC_60559_ATTRIB_EVALUATION_FORMAT__ The integer constant 202401L.
__STDC_IEC_60559_ATTRIB_OPTIMIZATION__ The integer constant 202401L.
__STDC_IEC_60559_ATTRIB_REPRODUCIBLE__ The integer constant 202401L.
__STDC_IEC_60559_ATTRIB_ALTERNATE_EXCEPTION_HANDLING__ The integer constant 202401L.
5.3 Standard headers
The identifiers specified in this document are defined or declared by the associated header if and only if the
implementation defines the relevant feature macros (5.2) and
__STDC_WANT_IEC_60559_ATTRIB_EXT__
is defined as a macro at the point in the source file where the header is first included.
6 Standard pragmas
C23 provides standard pragmas (C23, 6.10.8) for specifying certain attributes pertaining to floating-point
behavior within a compound statement or file. This document extends this practice by introducing additional
standard pragmas to support attributes recommended by ISO/IEC 60559:
#pragma STDC FP_FLT_EVAL_METHOD width
#pragma STDC FP_DEC_EVAL_METHOD width
#pragma STDC FP_ALLOW_VALUE_CHANGING_OPTIMIZATION on-off-switch
#pragma STDC FP_ALLOW_ASSOCIATIVE_LAW on-off-switch
#pragma STDC FP_ALLOW_DISTRIBUTIVE_LAW on-off-switch
#pragma STDC FP_ALLOW_MULTIPLY_BY_RECIPROCAL on-off-switch
#pragma STDC FP_ALLOW_ZERO_SUBNORMAL on-off-switch
#pragma STDC FP_ALLOW_CONTRACT_FMA on-off-switch
#pragma STDC FP_ALLOW_CONTRACT_OPERATION_CONVERSION on-off-switch
#pragma STDC FP_ALLOW_CONTRACT on-off-switch
#pragma STDC FP_REPRODUCIBLE on-off-switch
#pragma STDC FENV_EXCEPT action except-list
width: specified with the pragmas (7.2, 7.3)
on-off-switch: specified in C23, 6.10.8
action, except-list: specified with the pragma (10.1)
© ISO/IEC 2025 – All rights reserved
7 Evaluation formats
7.1 General
This clause applies to implementations that define:
__STDC_IEC_60559_ATTRIB_EVALUATION_FORMAT__
C23 gives implementations the flexibility to evaluate operations to the format of the wider operand or to
a still wider evaluation format. The values of the macros FLT_EVAL_METHOD (C23, 5.3.5.3.3 and H.3) and
DEC_EVAL_METHOD (C23, 5.3.5.3.4 and H.3) characterize these evaluation methods. Though C23 does not
provide means for the user to control the evaluation method, some implementations provide such controls
as extensions. ISO/IEC 60559 recommends an attribute for this purpose. The following subclauses (7.2 and
7.3) specify pragmas in to control the evaluation method. These evaluation method pragmas, like
the FENV_ROUND (C23, 7.6.3) and FENV_DEC_ROUND (C23, 7.6.4) pragmas, affect translation-time expression
evaluation and constants.
NOTE As specified in C23, 6.7.2, the value of the initializer for an object declared with storage-class specifier
constexpr is constrained to be exactly representable in the target type. Thus, an evaluation method pragma whose
scope includes the declaration can affect the validity of the declaration.
7.2 Evaluation method pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_FLT_EVAL_METHOD width
Constraints
The width parameter shall be -1, 0, DEFAULT, or another value supported by the implementation.
Description
The FP_FLT_EVAL_METHOD pragma sets the evaluation method for standard floating types and for binary
interchange and extended floating types to the evaluation method represented by width. The parameter
width is an expression in one of the forms:
decimal-constant
- decimal-constant
DEFAULT
where the value of the expression is a possible value of the FLT_EVAL_METHOD macro, as specified in C23,
5.3.5.3.3 and H.3. An expression represents the evaluation method corresponding to its value (C23, 5.3.5.3.3
and H.3) and DEFAULT designates the implementation’s default evaluation method (characterized by the
FLT_EVAL_METHOD macro). The width parameter may be -1, 0, or DEFAULT. Which, if any, other values of width
are supported is implementation-defined. The pragma shall occur either outside external declarations or
preceding all explicit declarations and statements inside a compound statement. When outside external
declarations, the pragma takes effect from its occurrence until another FP_FLT_EVAL_METHOD pragma is
encountered, or until the end of the translation unit. When inside a compound statement, the pragma takes
effect from its occurrence until another FP_FLT_EVAL_METHOD pragma is encountered (including within
a nested compound statement), or until the end of the compound statement; at the end of a compound
statement the state for the pragma is restored to its condition just before the compound statement.
© ISO/IEC 2025 – All rights reserved
7.3 Evaluation method pragma for decimal floating types
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_DEC_EVAL_METHOD width
Constraints
The width parameter shall be -1, 1, DEFAULT, or another value supported by the implementation.
Description
The FP_DEC_EVAL_METHOD pragma sets the evaluation method for decimal interchange and extended floating
types to the evaluation method represented by width. The parameter width is an expression in one of the forms:
decimal-constant
- decimal-constant
DEFAULT
where the value of the expression is a possible value of the DEC_EVAL_METHOD macro, as specified in C23,
5.3.5.3.4 and H.3. An expression represents the evaluation method corresponding to its value (C23, 5.3.5.3.4
and H.3) and DEFAULT designates the implementation’s default evaluation method (characterized by the
DEC_EVAL_METHOD macro). The width parameter may be -1, 1, or DEFAULT. Which, if any, other values of width
are supported is implementation-defined. The pragma shall occur either outside external declarations or
preceding all explicit declarations and statements inside a compound statement. When outside external
declarations, the pragma takes effect from its occurrence until another FP_DEC_EVAL_METHOD pragma is
encountered, or until the end of the translation unit. When inside a compound statement, the pragma takes
effect from its occurrence until another FP_DEC_EVAL_METHOD pragma is encountered (including within
a nested compound statement), or until the end of the compound statement; at the end of a compound
statement the state for the pragma is restored to its condition just before the compound statement.
7.4 Effective evaluation method macros
The macros FLT_EVAL_METHOD (C23, 5.3.5.3.3 and H.3) and DEC_EVAL_METHOD (C23, 5.3.5.3.4 and
H.3) characterize the default evaluation method. Their values are constant expressions, suitable for use in
conditional expression inclusion preprocessing directives. They are not affected by the evaluation method
pragmas, so it is possible they do not reflect the effective evaluation method.
The header defines macros FLT_EVAL_METHOD_EFFECTIVE and DEC_EVAL_METHOD_EFFECTIVE that are
similar to the macros FLT_EVAL_METHOD and DEC_EVAL_METHOD, except that they characterize the
effective evaluation method at the point in the program where the macro is used. Thus, they reflect the state
of any evaluation method pragmas (7.2, 7.3) that are in effect. These macros shall not be used in conditional
expression inclusion preprocessing directives.
7.5 Evaluation type macros
The types with an _t suffix (e.g. float_t) (C23, 7.12.1 and H.11), which are defined to match
evaluation formats, reflect the evaluation method where no evaluation method pragma is in effect. For each
of these types, there is a type-like macro in with the same name which expands to a designation for
the type whose range and precision are used for evaluating operations and constants of the corresponding
standard, binary, or decimal floating type. The macro reflects the actual evaluation method, which can be
determined by an evaluation method pragma. Use of #undef to remove the macro definition will ensure that
the actual type is referred to (as though no evaluation method pragma was in effect).
© ISO/IEC 2025 – All rights reserved
7.6 Evaluation formats for
The evaluation methods in C23 apply to floating-point operators, but not to math functions. Hence, they do
not apply to the ISO/IEC 60559 operations that are provided as library functions. This subclause specifies
a macro the user can define to cause the generic macros in to be evaluated like floating-point
operators.
Except for functions that round result to a narrower type, if the macro
__STDC_TGMATH_OPERATOR_EVALUATION__
is defined at the point in the program where is first included, the format of the generic parameters
of the function invoked by a type-generic macro is the evaluation format determined by the effective
evaluation method (see C23, 5.3.5.3.3, 5.3.5.3.4 and H.3) applied to the types of the arguments for generic
parameters. The semantic type of the expanded type-generic macro is as determined by the rules in C23,
7.27 and H.13 and is unchanged by the evaluation method. Neither the arguments for generic parameters nor
the result are narrowed to their semantic types. Thus, (if the macro __STDC_TGMATH_OPERATOR_EVALUATION__
is appropriately defined) the evaluation method affects the operations provided by type-generic macros and
floating-point operators in the same way. See 7.6, EXAMPLE.
The macro __STDC_TGMATH_OPERATOR_EVALUATION__ does not alter the conversion of classification macro
arguments to their semantic types (as specified in C23, 7.12.4).
EXAMPLE The following code uses wide evaluation to avoid overflow and underflow.
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#define __STDC_TGMATH_OPERATOR_EVALUATION__
#include
{
#pragma STDC FLT_EVAL_METHOD 1 /* to double */
float x, y, z;
...
z = sqrt(x * x + y * y);
}
Because of the evaluation method pragma, the sum of squares, whose semantic type is float, is eval-
uated with the range and precision of double , hence does not overf low or underf low. The expand-
ed macro sqrt acquires the semantic type of its argument: float. However, because the macro
__STDC_TGMATH_OPERATOR_EVALUATION__ is defined before the inclusion of , the sqrt macro behaves
like an operator with respect to the evaluation method and does not narrow its argument to its semantic type. Without
the definition of the macro __STDC_TGMATH_OPERATOR_EVALUATION__, the sqrt macro would expand to sqrtf, and
its evaluated argument would be converted to float, which can overflow or underflow.
8 Optimization controls
8.1 General
This clause applies to implementations that define:
__STDC_IEC_60559_ATTRIB_OPTIMIZATION__
ISO/IEC 60559 recommends attributes to allow and disallow value-changing optimizations, individually and
collectively. C23, Annex F disallows value-changing optimizations, except for contractions (which can be
controlled as a group with the FP_CONTRACT pragma). This clause provides pragmas to allow or disallow
certain value-changing optimizations, including those mentioned in ISO/IEC 60559.
The pragmas in this clause can be used to allow the implementation to do certain floating-point optimizations
that are generally disallowed because the optimization can change values of floating-point expressions.
These pragmas apply to all floating types. It is unspecified whether optimizations allowed by these pragmas
occur consistently, or at all. These pragmas (among other standard pragmas) apply to user code. They do not
apply to code for operators or library functions that is placed inline by the implementation.
© ISO/IEC 2025 – All rights reserved
Some of the pragmas allow optimizations based on identities of real number arithmetic that are not valid
for floating-point arithmetic (C23, 5.2.2.4 and F.9.3). Optimizations based on identities that are valid for
the implementation’s floating-point arithmetic are always allowed. Optimizations based on identities
derived from identities whose use is allowed (either by a standard pragma or by virtue of being valid for the
implementation’s floating-point arithmetic) may also be done.
These pragmas do not affect the requirements on volatile or atomic variables.
Each pragma shall occur either outside external declarations or preceding all explicit declarations and
statements inside a compound statement. When outside external declarations, the pragma takes effect, on
each optimization it controls, from its occurrence until another pragma that affects the same optimization
is encountered, or until the end of the translation unit. When inside a compound statement, the pragma
takes effect, on each optimization it controls, from its occurrence until another pragma that affects the
same optimization is encountered (including within a nested compound statement), or until the end of the
compound statement; at the end of a compound statement the state for allowing each optimization controlled
by the pragma is restored to its condition just before the compound statement.
8.2 The FP_ALLOW_VALUE_CHANGING_OPTIMIZATION pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_VALUE_CHANGING_OPTIMIZATION on-off-switch
Description
This pragma is equivalent to all the optimization pragmas specified below, with the same value of on-off-
switch (ON, OFF, or DEFAULT).
NOTE The FP_ALLOW_VALUE_CHANGING_OPTIMIZATION pragma does not affect the evaluation methods.
Nevertheless, an evaluation method characterized by a negative value of width (C23, 5.3.5.3.3, 5.3.5.3.4 and H.3) can
allow for indeterminable evaluation formats, hence unspecified result values.
8.3 The FP_ALLOW_ASSOCIATIVE_LAW pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_ASSOCIATIVE_LAW on-off-switch
Description
This pragma allows or disallows optimizations based on the associative laws for addition and multiplication
x + (y + z) = (x + y) + z
x × (y × z) = (x × y) × z
where on-off-switch is one of
ON – allow application of the associative laws
OFF – do not allow application of the associative laws
DEFAULT – “off”
It should be noted that this pragma allows optimizations based on similar mathematical identities involving
subtraction and division. For example, for ISO/IEC 60559 floating-point arithmetic, since the identity
x − y = x + (−y)
© ISO/IEC 2025 – All rights reserved
is valid (C23, F.9.2), this pragma also allows optimizations based on
x + (y − z) = (x + y) − z
Similarly, if the states for this pragma and the FP_ALLOW_MULTIPLY_BY_RECIPROCAL pragma (8.5) are both
“on”, then optimizations based on the following are allowed:
x × (y / z) = (x × y) / z
It should also be noted that for ISO/IEC 60559 floating-point arithmetic, since the commutative laws
x + y = y + x
x × y = y × x
are valid, the pragma allows optimizations based on identities derived from the associative and commutative
laws, such as
x + (z + y) = (x + y) + z
8.4 The FP_ALLOW_DISTRIBUTIVE_LAW pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_DISTRIBUTIVE_LAW on-off-switch
Description
This pragma allows or disallows optimizations based on the distributive laws for multiplication and division
x × (y + z) = (x × y) + (x × z)
x × (y − z) = (x × y) − (x × z)
(x + y) / z = (x / z) + (y / z)
(x − y) / z = (x / z) − (y / z)
where on-off-switch is one of
ON – allow application of the distributive laws
OFF – do not allow application of the distributive laws
DEFAULT – “off”
8.5 The FP_ALLOW_MULTIPLY_BY_RECIPROCAL pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_MULTIPLY_BY_RECIPROCAL on-off-switch
Description
This pragma allows or disallows optimizations based on the mathematical equivalence of division and
multiplication by the reciprocal of the denominator
x / y = x × (1 / y)
© ISO/IEC 2025 – All rights reserved
where on-off-switch is one of
ON – allow multiply by reciprocal
OFF – do not allow multiply by reciprocal
DEFAULT – “off”
8.6 The FP_ALLOW_ZERO_SUBNORMAL pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_ZERO_SUBNORMAL on-off-switch
Description
This pragma allows or disallows replacement of subnormal operands and results by zero, where on-off-
switch is one of
ON – allow replacement of subnormals with zero
OFF – do not allow replacement of subnormals with zero
DEFAULT – “off”
Within the scope of this pragma, the floating-point operations affected by the pragma are all floating-point
operators, implicit conversions (including the conversion of a value represented in a format wider than its
semantic type to its semantic type, as done by classification macros), and invocations of applicable functions
in , , , and for which macro replacement has not been suppressed
(C23, 7.1.4). Thus, subnormal operands and results of affected operations may be replaced by zero. Whether
the replacement raises the “inexact” and “underflow” floating-point exceptions is unspecified. Functions not
affected by the pragma behave as though no FP_ALLOW_ZERO_SUBNORMAL pragma were in effect at the site of
the call.
8.7 The FP_ALLOW_CONTRACT_FMA pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_CONTRACT_FMA on-off-switch
Description
This pragma allows or disallows contraction (C23, 6.5.1) of floating-point multiply and add or subtract (with
the result of the multiply)
x * y + z
x * y − z
x + y * z
x − y * z
where on-off-switch is one of
ON – allow contraction for floating-point multiply-add
OFF – do not allow contraction for floating-point multiply-add
© ISO/IEC 2025 – All rights reserved
DEFAULT – implementation defined whether “on” or “off”
NOTE ISO/IEC 60559 uses the term “synthesize” instead of “contract”.
8.8 The FP_ALLOW_CONTRACT_OPERATION_CONVERSION pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_CONTRACT_OPERATION_CONVERSION on-off-switch
Description
This pragma allows or disallows contraction (C23, 6.5.1) of a floating-point operation and a conversion (of
the result of the operation), where on-off-switch is one of
ON – allow contraction for floating-point operation-conversion
OFF – do not allow contraction for floating-point operation-conversion
DEFAULT – implementation defined whether “on” or “off”
Within the scope of this pragma, the floating-point operations affected by the pragma are all floating-point
operators, implicit conversions (including the conversion of a value represented in a format wider than its
semantic type to its semantic type, as done by classification macros), and invocations of applicable functions
in , , , and for which macro replacement has not been suppressed
(C23, 7.1.4). Thus, an affected operation may be contracted with a conversion of its result. Functions not
affected by the pragma behave as though no FP_ALLOW_CONTRACT_OPERATION_CONVERSION pragma were in
effect at the site of the call.
EXAMPLE For the code sequence
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_CONTRACT_OPERATION_CONVERSION ON
float f1, f2;
double d1, d2;
…
f1 = d1 * d2;
f2 = sqrt(d1);
the multiply (operation) and assignment (conversion) can be evaluated with just one rounding (to the range
and precision of float). If the on-off-switch for the pragma were OFF, then the multiply would be rounded
according to the evaluation method and the assignment would entail a second rounding. With the given
code, the sqrt function can be replaced by fsqrt, avoiding the need for a separate operation to convert the
double result of sqrt to float.
8.9 The FP_ALLOW_CONTRACT pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_ALLOW_CONTRACT on-off-switch
Description
This pragma allows or disallows contraction (C23, 6.5.1) for floating-point operations, where on-off-switch
is one of
ON – allow contraction for floating-point operations
© ISO/IEC 2025 – All rights reserved
OFF – do not allow contraction for floating-point operations
DEFAULT – implementation defined whether “on” or “off”
The optimizations controlled by this pragma include those controlled by the FP_ALLOW_CONTRACT_FMA and
FP_ALLOW_CONTRACT_OPERATION_CONVERSION pragmas.
This pragma is equivalent to the FP_CONTRACT pragma (C23, 7.12.3), also in : the two pragmas may
be used interchangeably, provided the implementation defines __STDC_WANT_IEC_60559_ATTRIB_EXT__.
9 Reproducibility
9.1 General
This clause applies to implementations that define
__STDC_IEC_60559_ATTRIB_REPRODUCIBLE__
ISO/IEC 60559 recommends an attribute to facilitate writing programs whose floating-point results and
exception flags will be reproducible on any implementation that supports the language and library features
used by the program. Such code must use only those features of the language and library that support
reproducible results. These features include ones with a well-defined binding to reproducible features of
ISO/IEC 60559, so that no unspecified or implementation-defined behavior is admitted.
This clause provides a pragma to support the ISO/IEC 60559 attribute for reproducible results and gives
requirements for programs to have reproducible results. Where the state of the pragma is “on”, floating-
point numerical results and exception flags are reproducible (given the same inputs, including relevant
environment variables) on implementations that define
__STDC_IEC_60559_ATTRIB_REPRODUCIBLE__
and that support the language and library features used by the source code, provided the source code uses a
limited set of features as described below (9.3).
An implementation that defines __STDC_IEC_60559_ATTRIB_REPRODUCIBLE__ also defines either
__STDC_IEC_60559_BFP__ or __STDC_IEC_60559_DFP__, or both. If the implementation defines
__STDC_IEC_60559_BFP__, it supports reproducible results for code using (binary) types float and double. If
the implementation defines __STDC_IEC_60559_DFP__, it supports reproducible results for code using types
_Decimal32, _Decimal64, and _Decimal128. If the implementation defines __STDC_IEC_60559_TYPES__, then it
supports reproducible results for code using its interchange floating types (C23, H.2.2). If the implementation
provides a set of correctly rounded math functions (C23, 7.33.9), then it supports reproducible results for
code using correctly rounded math functions from that set.
9.2 The FP_REPRODUCIBLE pragma
Synopsis
#define __STDC_WANT_IEC_60559_ATTRIB_EXT__
#include
#pragma STDC FP_REPRODUCIBLE on-off-switch
© ISO/IEC 2025 – All rights reserved
Description
This pragma enables or disables support for reproducible results. The pragma shall occur either outside
external declarations or preceding all explicit declarations and statements inside a compound state-
ment. When outside external declarations, the pragma takes effect from its occurrence until another
FP_REPRODUCIBLE pragma is encountered, or until the end of the translation unit. When inside a compound
statement, the pragma takes effect from its occurrence until another FP_REPRODUCIBLE pragma is encountered
(including within a nested compound statement), or until the end of the compound statement; at the end of a
compound statement the state for the pragma is restored to its condition just before the compound statement.
If the state of the pragma is “on”, then the effects of the following are implied:
#pragma STDC FENV_ACCESS ON
#pragma STDC FP_ALLOW_VALUE_CHANGING_OPTIMIZATION OFF
and if __STDC_IEC_60559_BFP__ is defined
#pragma STDC FP_FLT_EVAL_METHOD 0
and if __STDC_IEC_60559_DFP__ is defined
#pragma STDC FP_DEC_EVAL_METHOD 1
If the FP_REPRODUCIBLE pragma appears with the on-off-switch OFF under the effect of a FP_REPRODUCIBLE
pragma with on-off-switch ON, then the states of the FENV_ACCESS pragma, the value-changing optimization
pragmas, and the evaluation method pragmas (even an evaluation method pragma whose state was
explicitly changed under the effect of the pragma with on-off-switch ON) revert to their states prior to the
FP_REPRODUCIBLE pragma with on-off-switch ON. The FP_REPRODUCIBLE pragma with on-off-switch OFF has no
effect if it occurs where the state of the pragma is “off”.
The default state of the pragma is “off”.
Recommended practice: The implementation is encouraged to issue a diagnostic message if, where the state
of the FP_REPRODUCIBLE pragma is “on”, the source code uses a language or library feature whose results may
not be reproducible.
9.3 Reproducible code
1)
The following properties support code sequences in producing reproducible results.
— The code is under the effect of the FP_REPRODUCIBLE pragma (with state “on”).
— All floating-point operations used by the code are bound to ISO/IEC 60559 operations, as described in
C23, F.3 in Table F.2.
— The code does not contain any use that may result in undefined behavior. The code does not depend on
any behavior that is unspecified, implementation-defined, or locale-specific.
The restrictive properties below are examples, not a complete list. See also C23, Annex J. Although
the properties may not be necessary in all cases for reproducible code, the user is advised to follow the
restrictions to avoid common programming practices that would undermine reproducibility.
— The code does not use the long double type.
— The code does not use complex or imaginary types.
1) Of course, if the code uses optional features, results will be reproducible only on implementations that support those
features.
© ISO/IEC 2025 – All rights reserved
— If __STDC_IEC_60559_BFP__ is not defined by the implementation, the code does not use the float or
double types.
— Even if __STDC_IEC_60559_TYPES__ is defined, the code does not use extended floating types. (Even if
__STDC_IEC_60559_TYPES__ is defined, some interchange floating types are optional features.)
— The code does not depend on the payloads (C23, F.10.14) or sign bits of quiet NaNs.
— The code does not use signaling NaNs.
— The code does not depend on conversions between binary floating types and character sequences with
more than M + 3 significant decimal digits, where M is 17 if __STDC_IEC_60559_TYPES__ is not defined (by
the implementation), and M is 1 + p×log(2) , where p
...








Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.
Loading comments...