(member) functions merged by linker, causing incorrect behavior - by wfunc

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<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 775899 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 1/5/2013 11:46:12 PM
Access Restriction Public


Visual C++'s linker merges identical functions into a single function during optimization, which affects observable behavior by causing distinct pointer values to become equal, which is a bug.
Sign in to post a comment.
Posted by Patrick [MSFT] on 1/8/2013 at 4:46 PM
Hi Mike,

The issue you are seeing is due to an optimization called COMDAT folding which is performed by the linker. This optimization merges identical functions together and is key to reducing code size for C++ code, especially programs which are template heavy. And yes, it is the same issue reported on the link you reference.

You can disable this optimization by using the linker switch "/OPT:NOICF". This will produce the desired behaviour you want but at the cost of some increase in your binary size.

-- Visual C++ Compiler Team
Posted by Microsoft on 1/8/2013 at 12:11 AM
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 Mike Danes on 1/7/2013 at 7:37 AM
Probably the same as: https://connect.microsoft.com/VisualStudio/feedback/details/716004/merging-equivalent-functions-during-code-generation-leads-to-sub-standard-behavior
Posted by Macy [MSFT] on 1/5/2013 at 11:52 PM
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)