Bug 39541 - Templates class instantiation -name lookup
Summary: Templates class instantiation -name lookup
Status: RESOLVED DUPLICATE of bug 15272
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-24 10:10 UTC by Anubhav
Modified: 2009-04-16 20:38 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anubhav 2009-03-24 10:10:09 UTC
Hi,

Consider the code

struct A{ 
        void fn(){cout << "1";} 
}; 

template<class T> 
struct B{ 
        void fn(){cout << "2";} 
}; 


template<class T> 
struct C : A, B<T>{ 
        C(){ fn(); }  // fn is a non dependent name. 
}; 

int main(){ 
        C<int> c; 
}

In this case, it looks fairly intuitive that the call to 'fn' is ambiguous. However there are two things that I am not able to resolve

a) I cannot find anything in the Standard that talk about such a scenario. Going by the rules of non dependent names (bound in lookup phase 1), fn should be in fact bound to A::fn.

b) Comeau online compiler accepts this code and compiles it fine.

So, I want to confirm if gcc 4.1.1 behavior is right? Any relevant quotes from the Standard will also help.

Regards,
Anubhav.
Comment 1 Andrew Pinski 2009-04-16 20:38:28 UTC

*** This bug has been marked as a duplicate of 15272 ***