-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Clang Frontend Crash #76604
Labels
c++20
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]
duplicate
Resolved as duplicate
Comments
github-actions
bot
added
the
clang
Clang issues not falling into any other category
label
Dec 30, 2023
Crashes in trunk too: https://godbolt.org/z/r3Y8f7qK3 |
EugeneZelenko
added
c++20
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
crash
Prefer [crash-on-valid] or [crash-on-invalid]
and removed
clang
Clang issues not falling into any other category
labels
Dec 30, 2023
@llvm/issue-subscribers-clang-frontend Author: Anthony (a-n-t-h-o-n-y)
Frontend crash on clang 17.0.1
Godbolt Link:
C++20 #include <concepts>
template <typename T, std::size_t N>
struct S {
T x;
};
template <std::size_t N, template <std::integral, std::size_t> typename... T>
auto wow(T<int, N>... ts)
{
return (... + ts.x);
}
int main(){
return wow<3>(S<int, 3>{1}, S<int, 3>{2});
} |
@llvm/issue-subscribers-c-20 Author: Anthony (a-n-t-h-o-n-y)
Frontend crash on clang 17.0.1
Godbolt Link:
C++20 #include <concepts>
template <typename T, std::size_t N>
struct S {
T x;
};
template <std::size_t N, template <std::integral, std::size_t> typename... T>
auto wow(T<int, N>... ts)
{
return (... + ts.x);
}
int main(){
return wow<3>(S<int, 3>{1}, S<int, 3>{2});
} |
Simplified template <typename T>
concept req = false;
template <template <req> typename T>
void wow(T<int> ts); |
I realized this is #57410. Let's track the bug there. |
zyn0217
added a commit
that referenced
this issue
Jan 6, 2024
…parameters (#76811) This fixes the bug introduced by 6db007a. We construct placeholder template arguments for template-template parameters to avoid mismatching argument substitution since they have different depths with their corresponding template arguments. In this case, ```cpp template <template <Concept C> class T> void foo(T<int>); ``` T lies at the depth 0, and C lies at 1. The corresponding argument, of which there is exactly one, int, is at depth 0. If we consider the argument as the outermost one, then we would end up substituting 'int' into the wrong parameter T. We used to perform such placeholder construction during the context walk-up. In the previous patch, we slipped through that inadvertently because we would walk up to the parent, which is precisely a FileContext for template-template parameters, after adding innermost arguments. Besides, this patch moves the sanity check up to the context switch. That way, we avoid dereferencing null pointers if ND is unspecified. Closes #57410. Closes #76604. (The case is slightly different than that in #57410. We should *not* assume the surrounding context to be a file-scope one.)
justinfargnoli
pushed a commit
to justinfargnoli/llvm-project
that referenced
this issue
Jan 28, 2024
…parameters (llvm#76811) This fixes the bug introduced by llvm@6db007a. We construct placeholder template arguments for template-template parameters to avoid mismatching argument substitution since they have different depths with their corresponding template arguments. In this case, ```cpp template <template <Concept C> class T> void foo(T<int>); ``` T lies at the depth 0, and C lies at 1. The corresponding argument, of which there is exactly one, int, is at depth 0. If we consider the argument as the outermost one, then we would end up substituting 'int' into the wrong parameter T. We used to perform such placeholder construction during the context walk-up. In the previous patch, we slipped through that inadvertently because we would walk up to the parent, which is precisely a FileContext for template-template parameters, after adding innermost arguments. Besides, this patch moves the sanity check up to the context switch. That way, we avoid dereferencing null pointers if ND is unspecified. Closes llvm#57410. Closes llvm#76604. (The case is slightly different than that in llvm#57410. We should *not* assume the surrounding context to be a file-scope one.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c++20
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]
duplicate
Resolved as duplicate
Frontend crash on clang 17.0.1
Godbolt Link:
https://godbolt.org/z/8Pnq1nsnb
C++20
The text was updated successfully, but these errors were encountered: