https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93469
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- This is a bug in your libc headers (and I'm guessing you're on OS X). The aligned_alloc function should be declared for C++17 and later, irrespective of the _XOPEN_SOURCE value.