Skip to content
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

CTAD: crashes on clang::Expr::EvaluateAsConstantExpr #92596

Open
hokein opened this issue May 17, 2024 · 2 comments · May be fixed by #93533
Open

CTAD: crashes on clang::Expr::EvaluateAsConstantExpr #92596

hokein opened this issue May 17, 2024 · 2 comments · May be fixed by #93533
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@hokein
Copy link
Collaborator

hokein commented May 17, 2024

clang current crashes on the following code.

template <typename>
constexpr bool C = true;
template<class T1, typename T2>
struct Foo {
  template<class V> requires C<V> // Index of V in the Foo deduction guide is 2
  Foo(V, T1);
};

template<class T3>
using AFoo = Foo<T3, T3>;
AFoo afoo{0, 1};

The index of template parameter occurrence V in the require-clause of the synthesized AFoo deduction guide auto (T3, V) -> Foo<T3, T3>is wrong (2), it should be 1. We miss this case at https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplate.cpp#L2857-L2858.

@hokein hokein added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label May 17, 2024
@hokein hokein self-assigned this May 17, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 17, 2024

@llvm/issue-subscribers-clang-frontend

Author: Haojian Wu (hokein)

clang current crashes on the following code.
template &lt;typename&gt;
constexpr bool C = true;
template&lt;class T1, typename T2&gt;
struct Foo {
  template&lt;class V&gt; requires C&lt;V&gt; // Index of V in the Foo deduction guide is 2
  Foo(V, T1);
};

template&lt;class T3&gt;
using AFoo = Foo&lt;T3, T3&gt;;
AFoo afoo{0, 1};

The index of template parameter occurrence V in the require-clause of the synthesized AFoo deduction guide auto (T3, V) -&gt; Foo&lt;T3, T3&gt;is wrong (2), it should be 1. We miss this case at https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplate.cpp#L2857-L2858.

@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label May 17, 2024
@shafik
Copy link
Collaborator

shafik commented May 17, 2024

Confirmed: https://godbolt.org/z/KcfEqd69v

@shafik shafik added the confirmed Verified by a second party label May 17, 2024
hokein added a commit to hokein/llvm-project that referenced this issue May 28, 2024
In the llvm#90961 fix, we miss a
case where the undeduced template parameters of the underlying deduction
guide is not transformed, which leaves incorrect depth/index
information, and causes crash when evaluating the constraints.

This patch fix this missing case.

Fixes llvm#92596
Fixes llvm#92212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants