Search

[Codename Milan] Cannot specialize variadic template functions by AndreiTita

Closed

2
0
Sign in
to vote
Type: Bug
ID: 774025
Opened: 12/11/2012 6:59:29 AM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
As per the title. Replacing the return or argument types in the shown example produces the same error.
Details (expand)

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

Visual Studio 2012

Steps to reproduce

Try to compile this code:

template<int, typename... Args>
void myfunc(Args... args) { }

template<>
void myfunc<1, float>(float) { }

Product Language

English

Operating System

Windows 7 SP1

Operating System Language

English (UK)

Actual results

Compiler error c2785 ('void myfunc(Args...)' and 'void myfunc(float)' have different return types) and compiler error c2912 (explicit specialization 'void myfunc(float)' is not a specialization of a function template)

Expected results

Clean compilation.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/11/2013 at 9:53 AM
Hi: this issue has been fixed and the fix should show up in the next release of Visual C++

Thanks
Jonathan Caves
Visual C++ Compiler Team
Posted by UnitUniverse on 1/21/2013 at 3:38 AM
@AndreiTita:
Your code won't be compiled and, however, the following will:

///<Demo>
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <functional>
#include <conio.h>


#include "stdlib.h"
#include <iostream>

template<int, typename... Args>
void myfunc(Args... args)
{
}

template<>
void myfunc<1>(float)
{
}

int _tmain(int argc, TCHAR * argv[])
{
    myfunc<0, int>(1);
    myfunc<1, float>(1.0f);

    _getch();
    return 0;
}

///</Demo>
Posted by Microsoft on 12/11/2012 at 9:59 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/11/2012 at 7:50 AM
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.