Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Deferred Help for as Deferred


3
0
Sign in
to vote
Type: Bug
ID: 777184
Opened: 1/22/2013 1:22:06 PM
Access Restriction: Public
1
Workaround(s)
view
2
User(s) can reproduce this bug

Description

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.
Details
Sign in to post a comment.
Posted by Microsoft 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 Microsoft on 4/17/2013 at 3:18 PM
Hi:
    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.

Thanks,
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)
Sign in to post a workaround.
Posted by Sylwester Zaluga on 1/22/2013 at 1:27 PM
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
File Name Submitted By Submitted On File Size  
main.cpp 1/22/2013 443 bytes