- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I encounter the strange behavior of the Intel C++ Compiler.
The following program generates "Floating point exception" if optimization (at least -O1) is enabled:
#include <fenv.h> #include <stdio.h> int j = 0; int main(int argc, char *argv[]){ feenableexcept( FE_DIVBYZERO ); double r = 0.0; for(int k=0; k<2; k++) { double A[3] = {0.,0.,0.}; if(j) A[0] -= 1.0/r; printf("A = %e %e %e\n", A[0], A[1], A[2]); } }
Linux, 64bit. Compiler version: icc (ICC) 16.0.1 20151021.
If the optimization is disabled, no exception is generated. gcc also generates no exception.
Is everything correct?
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'll look into it further. In the mean time, can you use -fp-model strict?
Thanks,
Viet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When compiled with option -fp-model strict, the result is as it should be:
A = 0.000000e+00 0.000000e+00 0.000000e+00
A = 0.000000e+00 0.000000e+00 0.000000e+00

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