wrong this pointer in member function - by Debugini

Status : 


Sign in
to vote
ID 808270 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 11/11/2013 12:41:49 PM
Access Restriction Public


In Visual Studio 2013: This pointer is wrong in member function under certain circumstances involving virtual inheritance, multiple inheritance, using and function overloads.

The program works under Visual Studio 2010 (SP1) and Visual Studio 2012.
Sign in to post a comment.
Posted by Microsoft on 12/8/2013 at 12:55 PM
    Thanks for reporting the issue.
    A fix for this issue has been checked into the compiler sources. The fix should show up in future release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by UnitUniverse on 11/15/2013 at 4:18 PM

class Derived
: public virtual Aggregate
// : public Aggregate
    void crossCastEntry()
        //((Aggregate &)*this).crossCast(); // OK.
        //((Aggregate *)this)->crossCast(); // OK.
        //crossCast(); // OK.
        Aggregate::crossCast(); // Error.

    virtual ~Derived()

The issue exists in either virtual or non-virtual inheritance circumstances.

This should have been fixed as soon as possible because if there were not just only one base of a class exist(multi-inherited) took same named member to be operated, such kind of issues might cause problems unpredictable. Generally, people prefer to use the '::' rather than to-base casting to distinguish which base member would be used.
Posted by UnitUniverse on 11/15/2013 at 3:35 PM
It seems (isn't comfirmed yet) the same reason to cause both of the issues with this:

Posted by Microsoft on 11/11/2013 at 6:25 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 11/11/2013 at 12:51 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)