[Bug c++/22596] New: Impossible to explicitly instantiate particular overloaded function

phenning at lanl dot gov gcc-bugzilla@gcc.gnu.org
Thu Jul 21 18:48:00 GMT 2005


Compiling the following code with "g++ -c -fno-implict-templates" always generates code for the 
second definition of foo().  It appears that g++ is automatically deducing the template parameters from 
the function parameters, even though the template parameters are explicitly given in the explict 
instantiation.   This problem prevents explicitly instantiating the function

std::_Destroy<int*, std::allocator<int>>(int *, int *, std::allocator<int>);

from bits/stl_construct.h in the 4.x Common Library implementation.

This behavior has been seen in: 
i686-pc-linux-gnu gcc-3.4.2
powerpc-apple-darwin8 gcc-4.0.0 (20041026 Apple Computer build 4061) 
i686-pc-linux-gnu gcc-4.1.0 20050629 (experimental)

// -------------------------------

template<class T> struct A_class
{
  int do_it(int i) { return i+1; }
};

template<class A> int foo(A a)
{
  return a.do_it(1);
}

template<class A, class T> int foo(A_class<T> a)
{
  return a.do_it(2);
}

template int foo< A_class<int> >(A_class<int> a);

// -------------------------------

-- 
           Summary: Impossible to explicitly instantiate particular
                    overloaded function
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: phenning at lanl dot gov
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu, powerpc-apple-darwin8


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



More information about the Gcc-bugs mailing list