- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I'm testing the icpc compiler and found a curious case: if I compile the code below
[cpp]
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fenv.h>
using namespace std;
int main() {
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
cout << log10(0.0049999999992) <<endl;
return 0;
}
[/cpp]
If I compile it with icpc log10.cxx -lm -g, it runs ok and gives the right answer (-2.30103), but if I enable icpc log10.cxx -lm -g -fp-trap-all=all , I get a SIGFPE. I'm using icpc version icpc (ICC) 13.0.0 20120731 on Linux x86_64. Any ideas?
Cheers
Link Copied
- « Previous
-
- 1
- 2
- Next »
23 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sergey,
Thanks for your time. I'll wait the answer from the Intel Engineers.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>...
>>gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-3.4/iostream-source.html
>>gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-3.4/classstd_1_1basic__iostream.html
>>gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-3.3/cstdlib-source.html
I didn't find anything that could control a state of Floating-Point Unit or possibly related to SIGFPE exception. While we're waiting for a response from Intel I'll think what else could be done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here are a couple of notes:
- SIGFPE exception has to be raised by CRT-function signal
- If you have a complete set of sources of STL and CRT libraries for GCC you need to find all calls to signal function ( I don't expect too many ) and you could be closer to understanding what is wrong
- These calls could look like:
...
if( signal( SIGFPE, ( void ( cdecl * )( int ) )SignalHandler ) == SIGERR )
{
...
printf( "Failed to Set a Handler for Detection of a Floating-Point Error\n" );
...
}
...
and SignalHandler could look like:
...
void cdecl SignalHandler( int iSignalCode, int iSignalExtCode )
{
...
g_iSignalCode = iSignalCode; // Saves the Signal & Signal Extended Codes
g_iSignalExtCode = iSignalExtCode;
_reset87(); // Resets FPU
longjmp( jmpbuf, -1 ); // Restores calling environment, returns to 'setjump' with a code -1
...
}
...
- Take into account that processing of exceptions with signal is a Very Old Technology and it was replaced by a modern Try-Catch exceptions handling.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »