https://connect.microsoft.com/VisualStudio/feedback/details/2163090/internal-compiler-error-on-some-sfinae-code
Code that crashes the Visual C++ 2015 update 1 compiler, written for a
Stack Overflow answer, (
http://stackoverflow.com/a/20819867/464581):
<code>
#ifndef DO_BAD
# define DO_GOOD
#endif
#include <iostream>
template< class A, class B > struct Is_t_;
template< class Type > struct Is_t_<Type, Type> { using T = void; };
template< class A, class B >
using If_is_ = typename Is_t_<A, B>::T;
struct Bad_string
{
operator const char* () const { return "666!"; }
Bad_string( char const* = 0 ) {}
};
auto operator==( Bad_string const&, Bad_string const& )
-> bool
{ return true; }
struct Good_string
{
template< class Type, class Enabled_ = If_is_<const char*, Type>>
operator Type() const { return "42 :)"; }
Good_string( char const* = 0 ) {}
};
auto operator==( Good_string const&, Good_string const& )
-> bool
{ return true; }
#if defined( DO_GOOD )
using String = Good_string;
#elif defined( DO_BAD )
using String = Bad_string;
#else
# error "Define either DO_GOOD or DO_BAD, please."
#endif
auto main() -> int
{
String a, b;
(void) (a == "alfalfa"); // Errs for Bad_string
(void) (a + 1); // Compiles for Bad_string.
}
</code>
Compiler response:
<quote>
foo.cpp(26): fatal error C1001: An internal error has occurred in the
compiler.
(compiler file 'msc1.cpp', line 1421)
To work around this problem, try simplifying or changing the program
near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Internal Compiler Error in D:\installed\Microsoft Visual Studio
14.0\VC\BIN\cl.exe. You will be prompted to send an err
or report to Microsoft later.
</quote>
I think reporting one or two compiler bugs each week is ridiculous.
Still.
- Alf