Internal compiler error (VC2008SP1)

Back to Compiler bugs

Found 9.5.2009. It took me hours to reduce to this small snippet from an actual program.

#include <string>
#include <set>

class C
{
public:
    C(long a)
        : a_(a)
    {
    }

    ~C()
    {
        if (_InterlockedDecrement(&a_) == 0)
        {
        }
    }

    long a_;
};

template <typename Real>
void f(const Real& a, const Real& b = 0);

template <typename Real>
void f(const Real& a, const Real& b)
{
    C c(b);
}

void h2()
{
    f((double)0);
    "" + std::string() +  "" + std::string();
}

void g(void(*)())
{
}

void h()
{
    h2();
    g(h);
}

int main()
{
    return 0;
}