[libc-commits] [libc] [libc] Add noexcept to aligned_alloc declaration in full-build mode (PR #191236)

via libc-commits libc-commits at lists.llvm.org
Thu Apr 9 09:47:05 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Jeff Bailey (kaladron)

<details>
<summary>Changes</summary>

The extern "C" declaration of aligned_alloc in the proxy header lacked a noexcept specifier, producing warnings when compiled as C++. Added a __cplusplus guard so C++ gets noexcept while C compilation remains unaffected.

---
Full diff: https://github.com/llvm/llvm-project/pull/191236.diff


1 Files Affected:

- (modified) libc/hdr/func/aligned_alloc.h (+4) 


``````````diff
diff --git a/libc/hdr/func/aligned_alloc.h b/libc/hdr/func/aligned_alloc.h
index b3436dfee1f23..3c197f4671a76 100644
--- a/libc/hdr/func/aligned_alloc.h
+++ b/libc/hdr/func/aligned_alloc.h
@@ -11,7 +11,11 @@
 
 #ifdef LIBC_FULL_BUILD
 #include "hdr/types/size_t.h"
+#ifdef __cplusplus
+extern "C" void *aligned_alloc(size_t, size_t) noexcept;
+#else
 extern "C" void *aligned_alloc(size_t, size_t);
+#endif
 
 #else // Overlay mode
 

``````````

</details>


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


More information about the libc-commits mailing list