[clang] [clang][bytecode] Fix crash on __builtin_infer_alloc_token with struct argument (PR #178936)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 30 21:01:03 PST 2026


================
@@ -1398,8 +1398,12 @@ static bool interp__builtin_infer_alloc_token(InterpState &S, CodePtr OpPC,
       MaxTokensOpt.value_or(0) ? *MaxTokensOpt : (~0ULL >> (64 - BitWidth));
 
   // We do not read any of the arguments; discard them.
-  for (int I = Call->getNumArgs() - 1; I >= 0; --I)
-    discard(S.Stk, *S.getContext().classify(Call->getArg(I)));
+  for (int I = Call->getNumArgs() - 1; I >= 0; --I) {
+    if (OptPrimType T = S.getContext().classify(Call->getArg(I)))
+      discard(S.Stk, *T);
----------------
tbaederr wrote:

```suggestion
          discard(S.Stk, S.getContext().classify(Call->getArg(I)).value_or(PT_Ptr));
```

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


More information about the cfe-commits mailing list