https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99995
Bug ID: 99995 Summary: [11 Regression] FAIL: 17_intro/headers/c++1998/49745.cc with -std=gnu++20 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- In C++20 mode <memory> includes <bits/atomic_wait.h> which includes <unistd.h> for SYS_futex, and that means that POSIX truncate is declared, leading to: In file included from /home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/atomic_wait.h:44, from /home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/atomic_base.h:41, from /home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, from /home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/memory:78, from /home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/powerpc64le-unknown-linux-gnu/bits/stdc++.h:82, from <command-line>: /usr/include/unistd.h:1015: note: previous declaration 'int truncate(const char*, __off_t)' compiler exited with status 1 FAIL: 17_intro/headers/c++1998/49745.cc (test for excess errors) Excess errors: /home/jwakely/src/gcc/libstdc++-v3/testsuite/17_intro/headers/c++1998/49745.cc:22: error: 'int truncate' redeclared as different kind of entity This is only seen when adding -std=gnu++20 (or similar) to the test flags explicitly, and only when PCH is enabled so that -include bits/stdc++.h is added to the test flags, because otherwise that test doesn't include <memory>. But the underlying problem is that including <unistd.h> means Bug 49745 has returned: we include <unistd.h> from C++ library headers. This is only an issue for C++20 mode, and will fix itself when the code to use futexes moves into libstdc++.so rather than being in headers. In the meantime, we might want to XFAIL that test for c++20 mode.