Go to main content
Oracle® Developer Studio 12.6: C User's Guide

Exit Print View

Updated: July 2017
 
 

Please tell us how to improve our documentation:


0 of 500

0 of 500



0 of 500
Thank you for your feedback! If you want to participate in content improvement and share additional information, please click Feedback button.
Rate this document:

2.14 Preserving the Value of errno

With -fast, the compiler is free to replace calls to floating-point functions with equivalent optimized code that does not set the errno variable. Further, -fast also defines the macro __MATHERR_ERRNO_DONTCARE, which requests the compiler ignore ensuring the validity of errno and floating-point exceptions raised. As a result, user code that relies on the value of errno or an appropriate floating-point exception after a floating-point function call could produce inconsistent results.

One way around this problem is to avoid compiling such codes with -fast. However, if -fast optimization is required and the code depends on the value of errno being set properly after floating-point library calls, you should compile with the following options:

-xbuiltin=none -U__MATHERR_ERRNO_DONTCARE -xlibmopt=%none -xnolibmil

These options should follow -fast on the command line to inhibit the compiler from optimizing out such library calls and to ensure that errno is handled properly.