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

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 27 17:28:58 PDT 2021


mizvekov added inline comments.


================
Comment at: clang/lib/Sema/SemaConcept.cpp:751
+      return None;
+    Conjunction.emplace(S.Context, std::move(*Conjunction), std::move(*Next),
+                        CCK_Conjunction);
----------------
mizvekov wrote:
> rsmith wrote:
> > 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.
> The constructor used here takes both constraints by value:
> ```
>   NormalizedConstraint(ASTContext &C, NormalizedConstraint LHS,
>                        NormalizedConstraint RHS, CompoundConstraintKind Kind)
>       : Constraint{CompoundConstraint{
>             new (C) std::pair<NormalizedConstraint, NormalizedConstraint>{
>                 std::move(LHS), std::move(RHS)}, Kind}} { };
> ```
But I will also check if emplace is doing the right thing here or not.


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