Home Dashboard Directory Help
Search

ctp compiler crash on variadic template code by summerlight


Status: 

Closed
 as By Design Help for as By Design


2
0
Sign in
to vote
Type: Bug
ID: 771522
Opened: 11/18/2012 3:13:08 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

ctp compiler crashes on below code

template<typename... T>
struct a
{
    template<typename head, typename... remainder>
    void init()
    {
    }

    template<>
    void init()
    {
    }
};

int main()
{
}

Though above code is not legimate code (though msvc extension allows it), proper compile error/warning message is expected rather than compiler crash.
Details
Sign in to post a comment.
Posted by Microsoft on 12/4/2013 at 7:17 AM
Hi: this code, as shown, in the last example does compile and execute correctly with a recent build of the compiler.

Note: if I uncomment the "template<>" then I do get an error:

t502675.cpp(14) : error C2912: explicit specialization 'void a<>::init(void)' is not a specialization of a function template

This is correct: to be an explicit specialization the function needs to have a template argument that matches the first (non-variadic) template parameter - or to put it another way only a variadic template parameter can have an "empty" template argument.

Thanks
Jonathan Caves
Visual C++ Compiler Team
Posted by UnitUniverse on 12/6/2012 at 3:33 AM
@Microsoft: The title of this report should have been marked as '[Codename Milan]'. It's ignored by mistake by its author.
Posted by UnitUniverse on 12/6/2012 at 3:28 AM
// ConsoleApplication1.cpp : Defines the entry point for the console application.
// It can be compiled.

#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <iostream>


template<typename... T>
struct a
{
    template < typename head, typename... remainder >
    void init()
    {
    }

    //template <>
    void init()
    {
    }

    template <>
    void init<int>()
    {
    }
};

int _tmain(int argc, _TCHAR* argv[])
{
    a<> o1;

    o1.init<int, int>();
    o1.init<float>();
    o1.init<int>();
    o1.init();

    _getch();
    return 0;
}
Posted by UnitUniverse on 12/6/2012 at 3:20 AM
This might be compiled if i removed the third 'template' line (template <>):

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

#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <iostream>


template<typename... T>
struct a
{
    template<typename head, typename... remainder>
    void init()
    {
    }

    //template<>
    void init()
    {
    }
};

int _tmain(int argc, _TCHAR* argv[])
{
    a<> o1;

    o1.init<int>();
    o1.init();

    _getch();
    return 0;
}
Posted by Microsoft on 11/19/2012 at 10:03 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Microsoft Visual Studio Connect Support Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/19/2012 at 9: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.