[llvm-branch-commits] [clang] [Clang] Implement CWG 2282 (PR #203832)

Vlad Serebrennikov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jun 17 03:02:48 PDT 2026


================
@@ -3043,11 +3056,23 @@ bool Sema::FindAllocationFunctions(
       //   If no matching function is found and the allocated object type has
       //   new-extended alignment, the alignment argument is removed from the
       //   argument list, and overload resolution is performed again.
+      //
+      // C++20 [expr.new]p18:
+      //   If no matching function is found then
+      //     — if the allocated object type has new-extended alignment, the
+      //       alignment argument is removed from the argument list;
+      //     — otherwise, an argument that is the type’s alignment and has type
+      //       std::align_val_t is added into the argument list immediately
+      //       after the first argument;
+      //   and then overload resolution is performed again.
+      bool UseFallback = isAlignedAllocation(OriginalAlignedAllocationMode) ||
+                         (getLangOpts().CPlusPlus20 && getStdAlignValT());
----------------
Endilll wrote:

CWG2282 was accepted as a DR. Is there anything preventing us from backporting this to earlier language modes?

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


More information about the llvm-branch-commits mailing list