VS2010에서 nullptr의 알려진 버그

C++0x 2010. 9. 30. 23:57 Posted by 알 수 없는 사용자
안녕하세요.
이 글에서는 VS2010에서 nullptr의 버그를 간단하게 언급하겠습니다.
아래 코드는 문제 없이 컴파일 되고 실행이 됩니다.

#include "stdafx.h"


template<int> void f(){};

void g()
{
    f<nullptr>();
}

template<template <class> class> class C {};

void test()
{
    auto x = nullptr;
    x++; // should give error
    x += 1; // should give error
}

 int _tmain(int argc, _TCHAR* argv[])
{
    C<nullptr> c;
    test();

    return 0;
}


하지만 다음과 같은 세가지 버그가 존재합니다.

1. nullptr이 함수 템플릿의 non-type argument로서 사용이 됩니다. ( f<nullptr>(); )
2. nullptr이 template template argumen로서 사용이 됩니다. ( template<template <class> class> class C {}; )
3. nullptr에 대해서 몇몇 수학적 operation이 동작합니다. ( in test() )