This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/19112] New: assignment from function to template fails


I try to assign a template to another template. Direct assignment works, 
but when I try to assign the result of a function call, gcc fails. Under 
the given canditates the expected one is listed. 
 
 
following code fails using gcc: 
 
==================================================================== 
// template test for gcc 
// 
 
template<class TEST> 
class Pointer 
{ 
public: 
    Pointer(TEST initValue): m_data(initValue) {} 
    Pointer(Pointer<TEST> &other): m_data(other.m_data) {} 
    virtual ~Pointer() {} 
 
    //Pointer<TEST> &operator = (Pointer<TEST> &other) { m_data = 
other.m_data; return *this; } 
 
private: 
    TEST m_data; 
}; 
 
 
template<class TEST> 
class UsePointer 
{ 
public: 
    UsePointer(Pointer<TEST> &point) 
        : m_localCopy(point) 
    {} 
 
    UsePointer(Pointer<TEST> point) 
    : m_localCopy(point) 
    { 
    } 
private: 
    Pointer<TEST> m_localCopy; 
}; 
 
 
Pointer<int> getSomething() 
{ 
    Pointer<int> result(4); 
    return result; 
} 
 
 
int main(int argc, char* argv[]) 
{ 
    UsePointer<int> user(getSomething()); 
        return 0; 
} 
==================================================================== 
with following output 
==================================================================== 
dierk@hochofen:~/Entwicklung/eigenes$ gcc -v -save-temps -c templates.cpp -o 
templtest 
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs 
Configured with: ../src/configure -v 
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr 
--mandir=/usr/share/man --infodir=/usr/share/info 
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib 
--enable-nls --without-included-gettext --enable-__cxa_atexit 
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm 
--enable-java-awt=xlib --enable-objc-gc i486-linux 
Thread model: posix 
gcc version 3.3.5 (Debian 1:3.3.5-2) 
 /usr/lib/gcc-lib/i486-linux/3.3.5/cc1plus -E -D__GNUG__=3 -quiet -v 
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=5 -D_GNU_SOURCE 
templates.cpp templates.ii 
ignoring nonexistent directory "/usr/i486-linux/include" 
#include "..." search starts here: 
#include <...> search starts here: 
 /usr/include/c++/3.3 
 /usr/include/c++/3.3/i486-linux 
 /usr/include/c++/3.3/backward 
 /usr/local/include 
 /usr/lib/gcc-lib/i486-linux/3.3.5/include 
 /usr/include 
End of search list. 
 /usr/lib/gcc-lib/i486-linux/3.3.5/cc1plus -fpreprocessed templates.ii -quiet 
-dumpbase templates.cpp -auxbase-strip templtest -version -o templates.s 
GNU C++ version 3.3.5 (Debian 1:3.3.5-2) (i486-linux) 
        compiled by GNU C version 3.3.5 (Debian 1:3.3.5-2). 
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129567 
templates.cpp: In function `int main(int, char**)': 
templates.cpp:45: error: no matching function for call to `Pointer<int>:: 
   Pointer(Pointer<int>)' 
templates.cpp:9: error: candidates are: Pointer<TEST>::Pointer(Pointer<TEST>&) 
   [with TEST = int] 
templates.cpp:8: error:                 Pointer<TEST>::Pointer(TEST) [with 
TEST 
   = int] 
templates.cpp:45: error:   initializing argument 1 of ` 
   UsePointer<TEST>::UsePointer(Pointer<TEST>) [with TEST = int]' 
====================================================================

-- 
           Summary: assignment from function to template fails
           Product: gcc
           Version: 3.3.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot hentrich at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: linux
GCC target triplet: linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]