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++/16610] New: constructor template binding different than plain function for same types


in:
#include    <iostream>
template<typename T>
void Foo(T*const& t) { std::cout << "reference\n"; }
template<typename T, size_t s>
void Foo(T(&t)[s]) { std::cout << "array\n"; }
template<typename T>
struct Frob {
    Frob(T*const& t) { std::cout << "reference\n"; }
    template<size_t s>
    Frob(T(&t)[s]) { std::cout << "array\n"; }
    };

int main() {
    int* ri;
    int ra[10];
    Foo(ri);
    Foo(ra);
    Foo(new int[2]);
    Frob<int> f1(ri);
    Frob<int> f2(ra);
    Frob<int> f3(new int[2]);
    Frob<int> f4 = ri;
    Frob<int> f5 = ra;
    Frob<int> f6 = new int[2];
    }


you get:

~/ootbc/members/members/sweetie/test/src$ a.out
reference
array
reference
reference
reference
reference
reference
reference
reference

Ivan

-- 
           Summary: constructor template binding different than plain
                    function for same types
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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