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++/39534] New: Template name lookup


Hi,

I expect this code to print 2122 but it instead prints 2222.

#include <iostream>
using namespace std;

namespace my{
struct S{};
void f(S s, double d = 0){cout << "1";}
}

template<class T>
void h(){ T t; my::S s;
f(t, 0);                    // Line 1
f(s, 0);                    // Line 2
}

namespace my{  // reopen the namespace and add another overloaded function.
void f(S s, int d = 0){cout << "2";}
}

template<class T>
void g(){ T t; my::S s;
f(t, 0);                 // Line 3
f(s, 0);                 // Line 4
}

int main(){ h<my::S>();
g<my::S>();

Regards,
Anubhav.


-- 
           Summary: Template name lookup
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anubhav dot saxena at wipro dot com


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


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