http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46691

           Summary: Null pointer in template deduction
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ilpoil...@hotmail.com


Have a look at the following code:

template <typename T>
struct identity
{
    typedef T type;
};

template <typename T>
void f(T t, typename identity<T>::type* p)
{
}

int main()
{
    int a = 0;
    f(a, 0);

    return 0;
}

Compiling this on GCC 4.4.5 gives the following error:

g++ test.cpp

test.cpp: "error: no matching function for call to 'f(int&, int)'"

The 0 should match a null pointer. The code is accepted by Visual Studio 2008,
2010, and Comeau C++, all in strict mode.

g++ -v

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.4-8'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--with-arch-32=i586 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 20100728 (prerelease) (Debian 4.4.4-8)

Reply via email to