Skip to content

[C++17][clang:Frontend] Clang can't deduce the correct deduction guide. #67959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HoBoIs opened this issue Oct 2, 2023 · 5 comments
Closed
Labels
c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@HoBoIs
Copy link
Contributor

HoBoIs commented Oct 2, 2023

If there are two auto generated deduction guides from a templated and a non templated constructor we should choose the guide generated from the non-templated constructor. But clang can't deduce which one should we use. (gcc can)

https://godbolt.org/z/ee3e9qG78

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Oct 2, 2023
@HoBoIs HoBoIs changed the title Clang can't deduce the correct deduction guide. [C++17][clang:Frontend] [C++17][clang:Frontend] Clang can't deduce the correct deduction guide. Oct 2, 2023
@HoBoIs
Copy link
Contributor Author

HoBoIs commented Oct 2, 2023

The pull request #66487 Will solve the issue, once it is merged (It haven't been reviewed yet).

@Endilll Endilll added c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang Clang issues not falling into any other category labels Oct 2, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2023

@llvm/issue-subscribers-c-17

If there are two auto generated deduction guides from a templated and a non templated constructor we should choose the guide generated from the non-templated constructor. But clang can't deduce which one should we use. (gcc can)

https://godbolt.org/z/ee3e9qG78

@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2023

@llvm/issue-subscribers-clang-frontend

If there are two auto generated deduction guides from a templated and a non templated constructor we should choose the guide generated from the non-templated constructor. But clang can't deduce which one should we use. (gcc can)

https://godbolt.org/z/ee3e9qG78

@shafik
Copy link
Collaborator

shafik commented Oct 2, 2023

It is helpful to include reasonably sized code snippets so readers can understand the issue report in once place:

template<class T>
struct A
{
    A(T, T, int);  //#1
 
    template<class U>
    A(int, T, U);  //#2
};                 
 
A x(1, 2, 3); // Should choose #1

This looks like overload resolution to me from over.match.best.general p2.13.

Looks like the wording came from p0620r0 which was about deduction guides but I don't see how the specific example is deduction guides but I may be missing something.

@HoBoIs
Copy link
Contributor Author

HoBoIs commented Oct 3, 2023

You have to deduce the template parameter of A (to int) from the deduction guides generated from the constructors. The rule http://eel.is/c++draft/over.match.best.general#2.13 Says that the we have to use guide generated from the first constructor, but calng claims the deduction is ambigous.

@HoBoIs HoBoIs closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++17 clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants