Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2015 Internal Compiler Error when using inheriting constructors

Here's a 10-line C++11 program, vastly simplified from a program I'm working on:

template <typename T> class Base { public:
    template <typename S> Base(S x) {}
};
template <typename T> class Child : public Base<T> { public:
    using Base<T>::Base;
};
template <> class Child<int> : public Base<int> { public:
    using Base<int>::Base;
};

int main()
{
    Child<int> child(8.0f);
}

MSVC 2015 outputs:

1>------ Build started: Project: MyProject, Configuration: Debug Win32 ------
1>  filename.cpp
1>path\to\filename(10): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'msc1.cpp', line 1393)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information

N.B. MSVC 2015 support for inheriting constructors is new with that version.

I've already submitted a bug report on this, since at the very least the compiler should not crash. However, can I have confirmation that this is correct C++ usage/a workaround?

Bug report here

like image 687
imallett Avatar asked Jul 25 '15 20:07

imallett


1 Answers

As mentioned in the comments, it seems to be a MSVC issue. Quickly compiled it with Clang and -std=c++11, no problems there.

like image 141
Nibor Avatar answered Oct 15 '22 22:10

Nibor