Implementation defined behavior control

C++ language
General topics
Flow control
Conditional execution statements
Iteration statements
Jump statements
function declaration
lambda function declaration
function template
inline specifier
exception specifications (deprecated)
noexcept specifier (C++11)
decltype specifier (C++11)
cv specifiers
storage duration specifiers
constexpr specifier (C++11)
auto specifier (C++11)
alignas specifier (C++11)
alternative representations
typedef declaration
type alias declaration (C++11)
attributes (C++11)
implicit conversions
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-style and functional cast
Memory allocation
Class-specific function properties
Special member functions
class template
function template
template specialization
parameter packs (C++11)
Inline assembly

Implementation defined behavior is controlled by #pragma directive.


[edit] Syntax

#pragma pragma_params (1)
_Pragma ( string-literal ) (2) (since C++11)
1) Behaves in implementation-defined manner (unless pragma_params is one of the standard pragmas shown below
2) Removes the L prefix (if any), the outer quotes, and leading/trailing whitespace from string-literal, replaces each \" with " and each \\ with \, then tokenizes the result (as in translation stage 3), and then uses the result as if the input to #pragma in (1)

[edit] Explanation

Pragma directive controls implementation-specific behavior of the compiler, such as disabling compiler warnings or changing alignment requirements. Any pragma that is not recognized is ignored.

[edit] Standard pragmas

The following three pragmas are defined by the language standard:

#pragma STDC FENV_ACCESS arg (1)
#pragma STDC FP_CONTRACT arg (2)
#pragma STDC CX_LIMITED_RANGE arg (3)

where arg is either ON or OFF or DEFAULT.

1) If set to ON, informs the compiler that the program will access or modify floating-point environment, which means that optimizations that could subvert flag tests and mode changes (e.g., global common subexpression elimination, code motion, and constant folding) are prohibited. The default value is implementation-defined, usually OFF.
2) Allows contracting of floating-point expressions, that is optimizations that omit rounding errors and floating-point exceptions that would be observed if the expression was evaluated exactly as written. For example, allows the implementation of (x*y) + z with a single fused multiply-add CPU instruction. The default value is implementation-defined, usually ON.
3) Informs the compiler that multiplication, division, and absolute value of complex numbers may use simplified mathematical formulas (x+iy)×(u+iv) = (xu-yv)+i(yu+xv), (x+iy)/(u+iv) = [(xu+yv)+i(yu-xv)]/(u2
, and |x+iy| = x2
, despite the possibility of intermediate overflow. In other words, the programmer guarantees that the range of the values that will be passed to those function is limited. The default value is OFF

The behavior of the program is undefined if any of the three pragmas above appear in any context other than outside all external declarations or preceding all explicit declarations and statements inside a compound statement.

[edit] External links