- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please investigate a potential divide by 0 is ignored by Intel C++ compiler ( v13.x / W5 level of warnings / no warning or remark displayed ). I've done a verification with Microsoft C++ compiler and it reports:
...
double dX = 1.0L;
double dResult = (-dX + dX )/(-dX + dX );
...
..\Common\PrtTests.cpp(21076) : warning C4723: potential divide by 0
...
Thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If this compiles correctly, the result should be NaN, possibly set at compile time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>>double dResult = (-dX + dX )/(-dX + dX );>>>
If it compiles it should return a NAN.I used such a code to emulate a NaN returning to the caller.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the event that the compiler (version you have) is faulty and returns 0.0 as opposed to NaN, then try using "volatile double dX = 1.0L;"
IOW force the compiler to generate code to perform the calculation (as opposed to having the optimization pre-compute the result).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page