Search

C++: Inconsistent explicit interface override behavior by Matthew P. Del Buono

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 684720
Opened: 8/18/2011 4:53:06 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
Explicit overrides of an interface are not handled consistently in all situations. Specifically, a C3241 error can occur in some function signatures but not others. The following code works fine:


class IFoo
{
public:
    virtual bool foo() = 0;
};

class Bar : public IFoo
{
public:
    bool IFoo::foo() { return true; }
};


However, if the function signature were changed to `bool foo() const` an error C3241 occurs, claiming that the function was not introduced by IFoo. This error is incorrect.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

Attempt to compile the following C++ code


class IFoo
{
public:
    virtual bool foo() const = 0;
};

class Bar : public IFoo
{
public:
    bool IFoo::foo() const { return true; }
};

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

error C3241: 'bool Bar::foo(void)' : this method was not introduced by 'IFoo'

Expected results

Compiles successfully. Or, if this is intended to be an error, the case without 'const' should not compile successfully (and the error should be clearer).
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 8/19/2011 at 3:43 PM
Hi:
    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 MS-Moderator10 [Feedback Moderator] on 8/18/2011 at 9:07 PM
Thank you for submitting feedback on Visual Studio 2010 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 MS-Moderator01 on 8/18/2011 at 5:40 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.