Home Dashboard Directory Help
Search

VS2012 - Incorrect code generation by ludde_


Status: 

Closed


3
0
Sign in
to vote
Type: Bug
ID: 786097
Opened: 5/2/2013 4:14:10 AM
Access Restriction: Public
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

Incorrect code is generated for certain branchless operations with the 'char' type.
In this case:
bb |= (bb >= 'A' && bb <= 'Z') ? 32 : 0;

The compiler generates:
mov         eax,19h
cmp         ah,al     <-- wtf is this, eax is a constant!?
sbb         eax,eax
and         ecx,0FFFFFFE0h
add         ecx,20h
or         cl,dl

which is clearly broken.
Details
Sign in to post a comment.
Posted by Microsoft on 5/7/2013 at 9:15 AM
Hi, thanks for the report. This is a bug in the compiler optimizer. This will be fixed in a future release.

If you need a source code workaround you can disable optimizations around the function you showed has the bad codegen.
#pragma optimize("", off)
static bool Equals(const char *a, const char *b) {
...
#pragma optimize("", on)

If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance.
For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.

I am closing this MSConnect item. Feel free to respond if you need anything else.

Thanks,
Eric Brumer - Microsoft Visual C++
Posted by Microsoft on 5/2/2013 at 10:00 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 5/2/2013 at 4:50 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)
Sign in to post a workaround.
Posted by Viorel_ on 5/2/2013 at 11:35 AM
Make this change:


bb |= (bb >= 'A' && bb <= 'Z') ? char(32) : char(0);
File Name Submitted By Submitted On File Size  
compilerbug.zip 5/2/2013 2 KB