bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

aligned_alloc: Fix test failure on AIX 7.3 with ibm-clang


From: Bruno Haible
Subject: aligned_alloc: Fix test failure on AIX 7.3 with ibm-clang
Date: Fri, 18 Aug 2023 19:01:59 +0200

On AIX 7.3.1, with ibm-clang as compiler, I see a unit test failure:

FAIL: test-aligned_alloc
========================

../../gltests/test-aligned_alloc.c:52: assertion 'aligned2_blocks[i] != NULL' 
failed
FAIL test-aligned_alloc (exit status: 134)

The problem here is that ibm-clang, with option -O2, has optimized away
the configure test, assuming that aligned_alloc() never returns NULL.
But it _does_ return NULL in this case.

Fixing the configure test result enables the Gnulib override, and the unit test
then succeeds.


2023-08-18  Bruno Haible  <bruno@clisp.org>

        aligned_alloc: Fix test failure on AIX 7.3 with ibm-clang.
        * m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Use 'volatile', to
        disable optimization of ibm-clang -O2.
        * doc/posix-functions/aligned_alloc.texi: Update version info.

diff --git a/doc/posix-functions/aligned_alloc.texi 
b/doc/posix-functions/aligned_alloc.texi
index 7180cf3c12..557f11c6d4 100644
--- a/doc/posix-functions/aligned_alloc.texi
+++ b/doc/posix-functions/aligned_alloc.texi
@@ -11,7 +11,7 @@
 @item
 This function fails if the alignment argument is smaller than
 @code{sizeof (void *)} on some platforms:
-macOS 11.1, AIX 7.2.
+macOS 11.1, AIX 7.3.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/aligned_alloc.m4 b/m4/aligned_alloc.m4
index 8b4c10102e..f546c6ae80 100644
--- a/m4/aligned_alloc.m4
+++ b/m4/aligned_alloc.m4
@@ -1,4 +1,4 @@
-# aligned_alloc.m4 serial 5
+# aligned_alloc.m4 serial 6
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,15 +14,16 @@ AC_DEFUN([gl_FUNC_ALIGNED_ALLOC]
 
   gl_CHECK_FUNCS_ANDROID([aligned_alloc], [[#include <stdlib.h>]])
   if test $ac_cv_func_aligned_alloc = yes; then
-    dnl On macOS 11.1 and AIX 7.2, aligned_alloc returns NULL when the 
alignment
-    dnl argument is smaller than sizeof (void *).
+    dnl On macOS 11.1 and AIX 7.3.1, aligned_alloc returns NULL when the
+    dnl alignment argument is smaller than sizeof (void *).
     AC_CACHE_CHECK([whether aligned_alloc works for small alignments],
       [gl_cv_func_aligned_alloc_works],
       [AC_RUN_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <stdlib.h>
             ]],
-            [[return aligned_alloc (2, 18) == NULL;
+            [[void *volatile p = aligned_alloc (2, 18);
+              return p == NULL;
             ]])
          ],
          [gl_cv_func_aligned_alloc_works=yes],






reply via email to

[Prev in Thread] Current Thread [Next in Thread]