vc++ shift produces inconsistent result - by PMacTensilica

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.

Sign in
to vote
ID 731270 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/14/2012 6:18:13 PM
Access Restriction Public


Compile the code below with /O2 with vc2010 sp1. It produces the wrong result. see steps to reproduce for actual output.

vc2010sp1 x64 is correct
vc2008sp1 x86 is correct

vc2010 no sp x86 shows the bug
vc2010 sp1 x86 shows the bug

Q:\temp>type x.c

#include <stdio.h>
unsigned int tn6__o0 = 0xcd00abcd;
int main()
        unsigned int tn23__i0;
        tn23__i0 = ((((unsigned int)((((int)((tn6__o0) << 8))) >> 31)) & 0x7fffffU));
        printf("tn23 is 0x%x \n",tn23__i0);

Sign in to post a comment.
Posted by Microsoft on 5/9/2012 at 10:49 AM
Thanks for taking the time to report this issue. I can confirm the incorrect codegen you are seeing with VS2010sp1. I can happily report that a fix is already available in the VS11 Beta. Please let me know if you need any additional information on how to work around this problem in earlier versions of Visual Studio.

ian Bearman
Principal Software Developer
VC++ Code Generation and Optimization
Posted by Microsoft on 5/9/2012 at 1:24 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 MS-Moderator01 on 3/14/2012 at 6:53 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(