https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69680

            Bug ID: 69680
           Summary: stdlib.h does not declare aligned_alloc
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeff.science at gmail dot com
  Target Milestone: ---

When I use aligned_alloc, I am told to include stdlib.h to provide a
declaration, but I have already done so.

VERSION

$ gcc-5 -v
Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/5.3.0/libexec/gcc/x86_64-apple-darwin14.5.0/5.3.0/lto-wrapper
Target: x86_64-apple-darwin14.5.0
Configured with: ../configure --build=x86_64-apple-darwin14.5.0
--prefix=/usr/local/Cellar/gcc/5.3.0
--libdir=/usr/local/Cellar/gcc/5.3.0/lib/gcc/5
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking
--enable-checking=release --enable-lto --with-build-config=bootstrap-debug
--disable-werror --with-pkgversion='Homebrew gcc 5.3.0 --without-multilib'
--with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin
--disable-nls --disable-multilib
Thread model: posix
gcc version 5.3.0 (Homebrew gcc 5.3.0 --without-multilib) 

COMPILATION

$ gcc-5 -c aligned_alloc.c 
aligned_alloc.c: In function 'my_malloc':
aligned_alloc.c:5:12: warning: implicit declaration of function 'aligned_alloc'
[-Wimplicit-function-declaration]
     return aligned_alloc(64,bytes);
            ^
aligned_alloc.c:5:12: warning: incompatible implicit declaration of built-in
function 'aligned_alloc'
aligned_alloc.c:5:12: note: include '<stdlib.h>' or provide a declaration of
'aligned_alloc'

CODE

$ cat aligned_alloc.c 
#include <stdlib.h>
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
void* my_malloc(size_t bytes)
{
    return aligned_alloc(64,bytes);
}
#else
#error Pointless
#endif

EXTRA

It seems that none of the GCC 5.3.0 headers declare this function...

$ find /usr/local/Cellar/gcc/5.3.0/ -name "*.h" -exec grep -H aligned_alloc {}
";"

Reply via email to