Floating-point state controls how floating-point operations behave, including contraction and rounding. Pragmas can change that state locally: a rounding mode takes effect at the pragma and returns to its prior value when the scope ends. section 16.3
A locally controlled computation
A distance calculation can disable contraction and select a rounding mode before calling sqrt: #pragma FP_CONTRACT OFF #pragma FENV_ROUND FE_TONEAREST return sqrt(x[0]*x[0] + x[1]*x[1]); The surrounding function can be marked [[reproducible]] when it temporarily changes global floating-point state but restores it before returning. section 16.3
The state matters for optimization and function contracts:
- [[unsequenced]] requires the function not to change relevant global state, while [[reproducible]] permits temporary changes that are restored. section 16.3
