Search

private template operators in C++ treated as public by Jesse Connell

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 667226
Opened: 5/6/2011 6:31:56 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
private template operators are compiled as public. I'm including a very trivial example in "steps to reproduce."

Thanks, Jesse
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010 SP1

What category (if any) best represents this feedback?

Compatibility

Steps to reproduce

#include <iostream>

class Test
{
private:
    template<typename T>
    static void operator << (T t)
    {
        std::cout << t;
    }
};

int main(int argc, char **argv)
{
    Test t;
    t << "But this is private!";
    return 0;
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

The code compiles without error

Expected results

Should result in compiler error related to inaccessibility of operator.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 5/24/2011 at 2:17 PM
Hi Jesse:
    Thanks for reporting the issue.
    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 5/8/2011 at 7:15 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 5/6/2011 at 7:14 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.