Signed double -0.0 vs 0.0 - MSVS2012 Visual C++ bug in x64 mode when compiled with /fp:fast /O2 - by George Yohng

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 754839 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 7/20/2012 10:46:52 AM
Access Restriction Public

Description

Signed double -0.0 vs 0.0 - MSVS2012 Visual C++ optimized mishandles the difference between these two values with unexpected results in x64 mode when a program is compiled with /fp:fast /O2

Google V8 engine crashes badly because of this bug with /fp:fast and /O2 on x64

Sign in to post a comment.
Posted by Microsoft on 7/25/2012 at 10:20 AM
This is actually by design. Under /fp:fast, -0.0 is not differentiated from +0.0, and so when given “negative ? -0.0 : 0.0;” the optimizer is allowed to treat them as the same and pick to always return one of them.

/fp:fast also enables other optimizations that illustrate this. For example, given:
    -(x – y)
With /fp:fast, we are allowed to optimize this to:
    y – x
If x and y are the same (ie 1.0), the initial expression gives us -0.0 while the second expression gives us 0.0.

Shayne Hiet-Block
VC++ Code Generation and Optimization Team
Posted by Microsoft on 7/23/2012 at 12:34 AM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 7/20/2012 at 10:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)