C++ compiler bug - vtable pointer put at wrong offset in 64-bit mode - by Sylwester Zaluga

Status : 

  Deferred<br /><br />
		The product team has reviewed this issue and has deferred it for consideration at a later time.<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 777184 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 1/22/2013 1:22:06 PM
Access Restriction Public


It appears that there is a bug in the C++ compiler. The bug manifests itself only in 64 bit mode in classes (and structs) with virtual functions, custom-aligned members (16-or-more byte alignment) and bit fields. If bit field in such class is the last member, then class instances will have the vtable pointer put at wrong offset (shifted by 8 bytes). As a result, calling virtual functions of such instance will crash the program.
To work around the problem and fix such class one can:
a) inherit from some other class that contain virtual functions/vtable pointer
b) move around class members so that bit field does not appear at the last position

The bug is present in both VS2010 & VS2012.
Sign in to post a comment.
Posted by Deon [MSFT] on 4/29/2014 at 12:29 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Xiang [MSFT] on 4/17/2013 at 3:18 PM
    We revisited the issues reported to us and a fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 2/12/2013 at 2:00 PM
Hi Sylwester,

Thank you for taking the time to provide your feedback. After reviewing your reported issue, in the context of all the issues reported to us, we have decided not to take any action on this feedback at this time. We will re-consider our decision for a future release. In the meantime, please continue using the workarounds you have already discovered.

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.

Karl Niu
VC++ Team
Posted by Microsoft on 1/22/2013 at 7:08 PM
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 1/22/2013 at 1:50 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)