Search

C++ compiler allows use of unspecialized member function template by Avery Lee

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 633274
Opened: 12/24/2010 7:52:39 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The C++ compiler allows a static member function template to be assigned to a function pointer without specialization. This produces invalid generated code that uses NULL as the function pointer instead of an expected compile error. I hit this when converting an existing static method to a template.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010 SP1 Beta

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

// cl templ.cpp
class Blah {
public:
    template<int x>
    static void foo();
};

template<int x>
void Blah::foo() {}

int main() {
    void (*p)();

    p = Blah::foo;
    p();
}

Product Language

English

Operating System

Windows XP

Operating System Language

English

Actual results

The code compiles successfully with compiler version 16.00.31118.01 (VS2010 SP1 beta), but the resultant code crashes.

This also happens with VS2005 SP1 (14.00.50727.762).

Expected results

Compile error. The online Comeau C/C++ 4.3.10.1 compiler rejects this code.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 1/11/2011 at 4:07 PM
Hello Avery Lee,

Thanks for reporting this bug. Yes, this is a pretty bad bug, thanks for finding it. We're working on fixing it for next release.

Thanks,
Ulzii Luvsanbat
Windows C++ Team
Posted by Microsoft on 12/26/2010 at 6:34 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 12/24/2010 at 8:21 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.