Home Dashboard Directory Help
Search

C++ compiler pointer arithmetic problem (wrong result with /Od optimization) by Ilias A


Status: 

Closed


1
0
Sign in
to vote
Type: Bug
ID: 778524
Opened: 2/5/2013 12:52:03 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

When trying to get a sum of 2 numeric value of addresses that belong to char buffer one of the terms is ignored depending on the presence of parentheses. This only happens with /Od optimization. With optimizations /O1 and /O2 the result of computation is always correct.
Details
Sign in to post a comment.
Posted by Microsoft on 11/13/2013 at 2:25 PM
Hi, we will address this in a future release. I am closing this MSConnect item. Feel free to respond if you need anything else.

Thanks,
Eric Brumer
Microsoft Visual C++ Team
Posted by Microsoft on 2/19/2013 at 1:25 PM
Hi, thanks for the bug report. I have confirmed that this is a compiler bug when optimizations are not enabled. Even without optimization, the compiler attempts to generate good code for x86 by combining elements into an efficient address mode (that can do base + index * scale addressing).

In this case, the compiler is failing to include the address of tmp_arr in the address mode correctly.

You can work around the bug by using a different code pattern (as in the assignment to v1) or by introducing a local variable for the second calculation ((unsigned long)(tmp_arr) + 1).

Thanks,
Mark Levine
Microsoft VC++ team
Posted by Microsoft on 2/5/2013 at 2:47 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/5/2013 at 1: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.
File Name Submitted By Submitted On File Size  
code.zip 2/5/2013 826 bytes