[libc++] Fix aligned_alloc tests FreeBSD
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Sun, 18 Oct 2020 15:05:01 +0000 (16:05 +0100)
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Sun, 18 Oct 2020 17:17:50 +0000 (18:17 +0100)
On FreeBSD we get the following error when passing zero as the requested
alignment: error: requested alignment is not a power of 2

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88820

libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp

index 49f17d6..be43647 100644 (file)
@@ -133,7 +133,8 @@ int main(int, char**)
     static_assert((std::is_same<decltype(srand(0)), void>::value), "");
 
 #if TEST_STD_VER > 14 && defined(TEST_HAS_ALIGNED_ALLOC)
-    static_assert((std::is_same<decltype(aligned_alloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(aligned_alloc(1, 0)), void*>::value),
+                  "");
 #endif
 
     static_assert((std::is_same<decltype(calloc(0,0)), void*>::value), "");
index da0e3c0..72a3cf8 100644 (file)
@@ -120,7 +120,8 @@ int main(int, char**)
     static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
 
 #if TEST_STD_VER > 14 && defined(TEST_HAS_ALIGNED_ALLOC)
-    static_assert((std::is_same<decltype(std::aligned_alloc(0,0)), void*>::value), "");
+    static_assert(
+        (std::is_same<decltype(std::aligned_alloc(1, 0)), void*>::value), "");
 #endif
 
     static_assert((std::is_same<decltype(std::calloc(0,0)), void*>::value), "");