-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] fix crash due to incorrect argument position in merging deduced template arguments #118041
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ed template arguments
@llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) ChangesFixes #113659 Full diff: https://github.com/llvm/llvm-project/pull/118041.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2ecd19bdc39448..7e78e7eb9ec0a3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -760,6 +760,7 @@ Bug Fixes to C++ Support
missing placeholder return type. (#GH78694)
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
+- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 62a0c30d995020..fad20b37a7d9a2 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -376,7 +376,7 @@ checkDeducedTemplateArguments(ASTContext &Context,
for (TemplateArgument::pack_iterator
XA = X.pack_begin(),
XAEnd = X.pack_end(), YA = Y.pack_begin(), YAEnd = Y.pack_end();
- XA != XAEnd; ++XA, ++YA) {
+ XA != XAEnd; ++XA) {
if (YA != YAEnd) {
TemplateArgument Merged = checkDeducedTemplateArguments(
Context, DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
@@ -384,6 +384,7 @@ checkDeducedTemplateArguments(ASTContext &Context,
if (Merged.isNull() && !(XA->isNull() && YA->isNull()))
return DeducedTemplateArgument();
NewPack.push_back(Merged);
+ ++YA;
} else {
NewPack.push_back(*XA);
}
diff --git a/clang/test/SemaTemplate/template-args-deduction-aggregates.cpp b/clang/test/SemaTemplate/template-args-deduction-aggregates.cpp
new file mode 100644
index 00000000000000..afe78d0873bb33
--- /dev/null
+++ b/clang/test/SemaTemplate/template-args-deduction-aggregates.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+
+// expected-no-diagnostics
+
+namespace GH113659 {
+template <class... Args> struct S {};
+struct T {};
+struct U {};
+
+template <class... Args> struct B : S<Args...>, Args... {};
+B b{S<T, U>{}};
+}
|
zyn0217
approved these changes
Nov 29, 2024
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/8581 Here is the relevant piece of the build log for the reference
|
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"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #113659