[PATCH] D106907: [clang] fix concepts crash on substitution failure during normalization

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 27 16:55:38 PDT 2021


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaConcept.cpp:744
                                           ArrayRef<const Expr *> E) {
-  assert(E.size() != 0);
-  auto First = fromConstraintExpr(S, D, E[0]);
----------------
Might be useful to keep this assert; it will make it clearer to future readers that this function isn't intended to handle this case.


================
Comment at: clang/lib/Sema/SemaConcept.cpp:751
+      return None;
+    Conjunction.emplace(S.Context, std::move(*Conjunction), std::move(*Next),
+                        CCK_Conjunction);
----------------
Doesn't this have a use-after-destruction bug? I'd expect `emplace` to first destroy its contained value and then construct a new one; in this case the second constructor argument looks like it'll be a reference to a destroyed object. I assume that's why the old code did the two-step construct and assign dance.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106907/new/

https://reviews.llvm.org/D106907



More information about the cfe-commits mailing list