- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- Report Inappropriate Content

**NaN, possibly set at compile time**... Thanks, Tim. It compiles. I know that a result of the expression has to be equal to

**NaN**and I'll do a verification if it sets at compile time. However, I really expected a warning or a remark from

**Intel C++ compiler**especially when option

**/W5**is used. I'll also do a verification with option

**/Wcheck**.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- Report Inappropriate Content

**ignored**by Intel C++ compiler... >> >>In the event that the compiler (version you have) is faulty and returns 0.0 as opposed to NaN... It doesn't return 0.0 and I didn't want to look or to take into account all the rest possible problems. Now, I confirm the problem and here are more details: Note: Verified with versions 12.x and 13.x of Intel C++ compiler on 32-bit and 64-bit Windows platforms.

**[ Test-Case 1 - /W5 /Wcheck options used ]**... double dX = 0.0L; dX = ( -1.0L + 1.0L )/( -1.0L + 1.0L ); dX = dX; ...

**[ COMPILATION Output 1 ]**... ..\DivTestApp.cpp(24): warning #39: division by zero dX = ( -1.0L + 1.0L )/( -1.0L + 1.0L ); ...

**[ Test-Case 2 - /W5 /Wcheck options used ]**... double dX = 1.0L; double dResult = ( -dX + dX )/( -dX + dX ); ...

**[ COMPILATION Output 2 ]**No Warning

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