[PATCH] D138914: Make evaluation of nested requirement consistent with requires expr.
Richard Trieu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 21 18:36:47 PST 2022
rtrieu added inline comments.
================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2339
+ Req->getConstraintExpr()->getSourceRange(), Satisfaction))
+ TransConstraint = Result[0];
+ assert(!Trap.hasErrorOccurred() && "Substitution failures must be handled "
----------------
I have found a crash here when it access vector `Result` without checking the size first, leading to out of bounds memory access. CReduce gave the following testcase:
```
template <class a, a> struct b;
template <bool c> using d = b<bool, c>;
template <class a, class e> using f = d<__is_same(a, e)>;
template <class a, class e>
concept g = f<a, e>::h;
template <class a, class e>
concept i = g<e, a>;
template <typename> class j {
template <typename k>
requires requires { requires i<j, k>; }
j();
};
template <> j();
```
`clang reduce.ii --std=c++20`
```
assertion failed at llvm/include/llvm/ADT/SmallVector.h:294 in reference llvm::SmallVectorTemplateCommon<clang::Expr *>::operator[](size_type) [T = clang::Expr *]: idx < size()
...
...
(anonymous namespace)::TemplateInstantiator::TransformNestedRequirement(clang::concepts::NestedRequirement*) clang/lib/Sema/SemaTemplateInstantiate.cpp:2339:25
...
...
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138914/new/
https://reviews.llvm.org/D138914
More information about the cfe-commits
mailing list