fredrik.eriksson

Coffee and a keyboard

Visual C++ SP1 introduced bug

Microsoft introduced a bug whit SP1.

struct undefined;

template<class T>
void func(T) {
}

template<class T>
struct _1 {
    T value;
};

int main(int argc, char* argv[])
{
#if defined(APPLY_WORKAROUND)
    ::func((_1<undefined>*)0);
#else
    func((_1<undefined>*)0);
#endif
}

This bug causes msvc to instantiate _1 The workaround is to qualifying the call eg:

::func((_1*)0);

This bug was introduced in SP1 Compile with the workaround:

cl compiler_bug.cpp /DAPPLY_WORKAROUND