[PATCH] D131423: [clang] fix frontend crash when evaluating type trait
YingChi Long via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 8 11:57:38 PDT 2022
inclyc created this revision.
Herald added a project: All.
inclyc added reviewers: aaron.ballman, gribozavr2.
inclyc added a subscriber: clang.
inclyc added a reviewer: NoQ.
inclyc published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Crash input:
template<class... Ts> bool b = __is_constructible(Ts...);
bool x = b<>;
See https://godbolt.org/z/q39W78hsK.
Fixes https://github.com/llvm/llvm-project/issues/57008
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131423
Files:
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp
Index: clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// Shouldn't crash here
+// Reported by https://github.com/llvm/llvm-project/issues/57008
+template<class... Ts> bool b = __is_constructible(Ts...);
+bool x = b<>;
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5304,6 +5304,8 @@
// variable t:
//
// T t(create<Args>()...);
+ if (Args.empty())
+ return false;
assert(!Args.empty());
// Precondition: T and all types in the parameter pack Args shall be
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131423.450896.patch
Type: text/x-patch
Size: 839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220808/6c12edf1/attachment.bin>
More information about the cfe-commits
mailing list