- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I searched a bit for similar issues but could not find anything like that. The problem occurs when I initialize a class' members with a NaN value. Here is a sample program.cc:
#include
#include
using namespace std;
class MyObject {
public:
double a;
double b;
MyObject(): a(NAN), b(NAN) {}
};
int main (int argc, char** argv) {
MyObject* my_obj = new MyObject();
cout my_obj->a endl; // BB deleted the redirection characters
cout my_obj->b endl; // Idem
delete my_obj;
return 0;
}
The output when compiled with the -O0 flag gives:
-1.99885
2.53385
and with the -Ox flag (x >= 1):
0
0
but it never gives the "right" output, though gcc does:
nan
nan
Note that if 'a' and 'b' are initialized with something else than NAN, it works fine.
Note also that if 'a' and 'b' are initialized within the {} of the constructor it also works.
I am using Intel Compiler 8.0 on Linux. Unfortunately I'm not the administrator of the system (it's inside a university), thus I cannot contact Intel's technical support nor upgrade to 8.1.
Any help would be much appreciated,
Olivier
I searched a bit for similar issues but could not find anything like that. The problem occurs when I initialize a class' members with a NaN value. Here is a sample program.cc:
#include
#include
using namespace std;
class MyObject {
public:
double a;
double b;
MyObject(): a(NAN), b(NAN) {}
};
int main (int argc, char** argv) {
MyObject* my_obj = new MyObject();
cout my_obj->a endl; // BB deleted the redirection characters
cout my_obj->b endl; // Idem
delete my_obj;
return 0;
}
The output when compiled with the -O0 flag gives:
-1.99885
2.53385
and with the -Ox flag (x >= 1):
0
0
but it never gives the "right" output, though gcc does:
nan
nan
Note that if 'a' and 'b' are initialized with something else than NAN, it works fine.
Note also that if 'a' and 'b' are initialized within the {} of the constructor it also works.
I am using Intel Compiler 8.0 on Linux. Unfortunately I'm not the administrator of the system (it's inside a university), thus I cannot contact Intel's technical support nor upgrade to 8.1.
Any help would be much appreciated,
Olivier
Link Copied
0 Replies
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