https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93469
Bug ID: 93469 Summary: memory header fails to compile with _XOPEN_SOURCE macro defined and -std=c++2a option specified Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: karen.arutyunov at gmail dot com Target Milestone: --- While packaging ICU 65.1 for build2 toolchain I end up with the following error on macOS 10.15.2 with g++ 9.2.0 (Homebrew GCC 9.2.0_2): In file included from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/bits/stl_algo.h:59, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/string:52, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/stdexcept:39, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/array:39, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/tuple:39, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/bits/unique_ptr.h:37, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/memory:80, from /Users/build/cfg/libicuuc-65.1.0-a.0.20200127171539.77d49624ec32/libicu/uc/unicode/localpointer.h:45, from /Users/build/cfg/libicuuc-65.1.0-a.0.20200127171539.77d49624ec32/libicu/uc/unicode/udata.h:23, from /Users/build/cfg/libicuuc-65.1.0-a.0.20200127171539.77d49624ec32/libicu/uc/udatamem.h:24, from /Users/build/cfg/libicuuc-65.1.0-a.0.20200127171539.77d49624ec32/libicu/uc/umapfile.cpp:26: /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/cstdlib:132:11: error: '::aligned_alloc' has not been declared 132 | using ::aligned_alloc; | ^~~~~~~~~~~~~ The issue seems to relate to libstdc++ headers and pops up if the C++20 standard is specified on the command line and a program defines the _XOPEN_SOURCE macro and includes the memory header. It can be reproduced with the following commands: % cat <<EOF >test.cxx #include <memory> int main (int argc, char* argv[]) { } EOF % g++-9 -D_XOPEN_SOURCE=500 test.cxx % g++-9 -std=c++2a test.cxx % g++-9 -D_XOPEN_SOURCE=500 -std=c++2a test.cxx In file included from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/bits/stl_algo.h:59, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/string:52, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/stdexcept:39, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/array:39, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/tuple:39, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/bits/unique_ptr.h:37, from /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/memory:80, from test.cxx:1: /usr/local/Cellar/gcc/9.2.0_2/include/c++/9.2.0/cstdlib:132:11: error: '::aligned_alloc' has not been declared 132 | using ::aligned_alloc; | ^~~~~~~~~~~~~