Skip to content

Clang rejects valid program with default argument #59200

@ranaanoop

Description

@ranaanoop

The following valid program is rejected by clang. Demo

template <typename T> class Container {                                                                                                                                                                                                                                                    
    public:                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                    
        template<typename U = T> 
        std::enable_if_t<std::is_same_v<T, int>> foo(const T&)
        {
            
        }
};                                                                                                                                                                                                                                                              

template<typename T>
void func(T&& callable)
{
    Container<int> c;
    (c.*callable)(4);
}
int main(){                                                                                                                                                                                                                                
                                                                                                                                                                                                                                             
  func(&Container<int>::foo); //works with gcc but not with clang and msvc

} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"rejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions