Skip to content

clang accepts ambiguous function name lookup when using operator() #22413

Closed
@rnburn

Description

@rnburn
Bugzilla Link 22039
Version trunk
OS All
CC @DougGregor,@rnburn

Extended Description

clang accepts this code:

#include <iostream>                                                                                 
                                                                                                    
struct A {                                                                                          
  void operator()(int) {                                                                            
    std::cout << "A::f\n";                                                                          
  }                                                                                                 
};                                                                                                  
                                                                                                    
struct B {                                                                                          
  void operator()() {                                                                               
    std::cout << "B::f\n";                                                                          
  }                                                                                                 
};                                                                                                  
                                                                                                    
struct C                                                                                            
  : A, B                                                                                            
{                                                                                                   
};                                                                                                  
                                                                                                    
int main() {                                                                                        
  C c;                                                                                              
  c();                                                                                              
  return 0;                                                                                         
} 

which should give an ambiguous name lookup error. Both gcc and intel's compiler correctly give the operator() is ambiguous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions