https://github.com/PlutoDog95 updated https://github.com/llvm/llvm-project/pull/196744
>From c43779b62181d30114c86793a2e18789c6f6ed42 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal <[email protected]> Date: Sat, 9 May 2026 23:34:40 +0530 Subject: [PATCH] [clang] Avoid recursion during variadic promotion of volatile class types Avoid recursive copy initialization when performing variadic argument promotion on volatile class types. Previously Clang could recurse indefinitely and crash with stack exhaustion while handling variadic constructor calls. Add a regression test for the issue. --- clang/docs/ReleaseNotes.rst | 3 +++ clang/lib/Sema/SemaExpr.cpp | 4 +++- clang/test/SemaCXX/volatile-vararg-recursion.cpp | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaCXX/volatile-vararg-recursion.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index fa19d4b576575..3cba99777511d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -470,6 +470,9 @@ Improvements to Clang's diagnostics - Clang now emits an error when implicitly casting a complex type to a built-in vector type. (#GH186805) +- Fixed a frontend crash caused by recursive variadic argument promotion + involving volatile class types (#GH196713). + - Added ``-Wnonportable-include-path-separator`` (off by default) to catch #include directives that use backslashes as a path separator. The warning includes a FixIt to change all the backslashes to forward slashes, so that the diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 98062afae4577..19f0b961a6fe7 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -935,7 +935,9 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) { // is a prvalue for the temporary. // FIXME: add some way to gate this entire thing for correctness in // potentially potentially evaluated contexts. - if (getLangOpts().CPlusPlus && E->isGLValue() && !isUnevaluatedContext()) { + if (getLangOpts().CPlusPlus && E->isGLValue() && + !isUnevaluatedContext() && + !E->getType().isVolatileQualified()) { ExprResult Temp = PerformCopyInitialization( InitializedEntity::InitializeTemporary(E->getType()), E->getExprLoc(), E); diff --git a/clang/test/SemaCXX/volatile-vararg-recursion.cpp b/clang/test/SemaCXX/volatile-vararg-recursion.cpp new file mode 100644 index 0000000000000..cf3490baccdd4 --- /dev/null +++ b/clang/test/SemaCXX/volatile-vararg-recursion.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace cwg535 { +class X { + X(const X &); +}; + +struct B { + X y; + B(...); +}; + +extern volatile B b1; +B b2(b1); // expected-error {{cannot pass object of non-trivial type 'volatile B' through variadic constructor; call will abort at runtime}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
