[clang] [CLANG] Fixes the crash on the use of nested requirements in require expressions (PR #169876)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 02:23:09 PST 2025


https://github.com/cor3ntin commented:

Thanks for working on this!
We are missing an instantiation scope when checking the satisfaction of nested requirements

```difff
@@ -7999,7 +7999,9 @@ concepts::Requirement *Sema::ActOnNestedRequirement(Expr *Constraint) {
 concepts::NestedRequirement *
 Sema::BuildNestedRequirement(Expr *Constraint) {
   ConstraintSatisfaction Satisfaction;
+  LocalInstantiationScope Scope(*this);
   if (!Constraint->isInstantiationDependent() &&
+      !Constraint->isValueDependent() &&
       CheckConstraintSatisfaction(nullptr, AssociatedConstraint(Constraint),
                                   /*TemplateArgs=*/{},
                                   Constraint->getSourceRange(), Satisfaction))
```

`CheckConstraintSatisfaction` already takes care to check that individual atomic constraints are constant expressions, but without an instantiation context this check in `TemplateInstantiator::TransformDecl` fails and we hit an assert later on.

```cpp
if (ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(D);
      PVD && SemaRef.CurrentInstantiationScope &&
      (SemaRef.inConstraintSubstitution() ||
       SemaRef.inParameterMappingSubstitution()) &&
      maybeInstantiateFunctionParameterToScope(PVD))
    return nullptr;
```

https://github.com/llvm/llvm-project/pull/169876


More information about the cfe-commits mailing list