This is not a reserved name in C++11 and C++14, so must not be defined.
Also use the appropriate feature test macros for the try_emplace members
of the Debug Mode maps.
libstdc++-v3/ChangeLog:
* include/bits/hashtable_policy.h (_Insert_base::try_emplace):
Do not define for C++11 and C++14.
* include/debug/map.h (try_emplace): Use feature test macro.
* include/debug/unordered_map (try_emplace): Likewise.
* testsuite/17_intro/names.cc: Define try_emplace before C++17.
Otherwise we get failures with toolchains that have _FORTIFY_SOURCE
defined already to a different value like 3.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names_fortify.cc: Undefine _FORTIFY_SOURCE.
Add a new testcase that repeats 17_intro/names.cc but with
_FORTIFY_SOURCE defined, to find problems in Glibc fortify wrappers like
https://sourceware.org/bugzilla/show_bug.cgi?id=32052 (which is fixed
now).
libstdc++-v3/ChangeLog:
PR libstdc++/116210
* testsuite/17_intro/names.cc (sz): Undef for versions of Glibc
that use it in the fortify wrappers.
* testsuite/17_intro/names_fortify.cc: New test.
Some of these are due to no longer using #pragma GCC system_header in
libstdc++ headers, some have been failing for longer and weren't
noticed.
libstdc++-v3/ChangeLog:
* include/parallel/algobase.h (search): Use sequential algorithm
for constant evaluation.
* include/parallel/algorithmfwd.h (search): Add
_GLIBCXX20_CONSTEXPR.
* include/parallel/multiway_merge.h: Remove stray semi-colon.
* include/parallel/multiseq_selection.h: Add diagnostic pragmas
for -Wlong-long warning.
* include/parallel/quicksort.h: Likewise.
* include/parallel/random_number.h: Likewise.
* include/parallel/settings.h: Likewise.
* include/parallel/workstealing.h: Replace ++ and -- on volatile
variables.
* testsuite/17_intro/names.cc: Skip names defined by
<tr1/random>.
* testsuite/20_util/pair/dangling_ref.cc: Skip test if Parallel
Mode is enabled.
* testsuite/20_util/tuple/dangling_ref.cc: Likewise.
We have several nearly identical tests under 17_intro/headers which only
differ in a -std option set using dg-options. Since the testsuite now
supports running tests with multiple -std options (and I test that
regularly) we don't need these duplicated tests. We can remove most of
them and let the testsuite decide which -std option to use.
In the all_attributes.cc case the content of the tests is slightly
different, but they can be combined into one test that defines macros
conditionally based on __cplusplus checks.
The stdc++.cc tests could also be combined this way, but for now I've
just kept one version for c++98 and one for all later standards.
For stdc++_multiple_inclusion.cc we can remove the body of the files and
just include stdc++.cc twice. This means we don't need to add includes
to both stdc++.cc and stdc++_multiple_inclusion.cc, we only need to
update one place.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/headers/c++1998/all_attributes.cc: Add
attribute names from later standards and remove dg-options.
* testsuite/17_intro/headers/c++1998/stdc++.cc: Add c++98_only
target selector.
* testsuite/17_intro/headers/c++1998/stdc++_multiple_inclusion.cc:
Remove content and include stdc++.cc twice instead.
* testsuite/17_intro/headers/c++2011/stdc++.cc: Replace
dg-options with c++11 target selector.
* testsuite/17_intro/headers/c++2011/stdc++_multiple_inclusion.cc:
Remove content and include stdc++.cc twice instead.
* testsuite/17_intro/headers/c++2011/all_attributes.cc: Removed.
* testsuite/17_intro/headers/c++2011/all_no_exceptions.cc: Removed.
* testsuite/17_intro/headers/c++2011/all_no_rtti.cc: Removed.
* testsuite/17_intro/headers/c++2011/all_pedantic_errors.cc: Removed.
* testsuite/17_intro/headers/c++2011/charset.cc: Removed.
* testsuite/17_intro/headers/c++2011/operator_names.cc: Removed.
* testsuite/17_intro/headers/c++2014/all_attributes.cc: Removed.
* testsuite/17_intro/headers/c++2014/all_no_exceptions.cc: Removed.
* testsuite/17_intro/headers/c++2014/all_no_rtti.cc: Removed.
* testsuite/17_intro/headers/c++2014/all_pedantic_errors.cc: Removed.
* testsuite/17_intro/headers/c++2014/charset.cc: Removed.
* testsuite/17_intro/headers/c++2014/operator_names.cc: Removed.
* testsuite/17_intro/headers/c++2014/stdc++.cc: Removed.
* testsuite/17_intro/headers/c++2014/stdc++_multiple_inclusion.cc: Removed.
* testsuite/17_intro/headers/c++2017/all_attributes.cc: Removed.
* testsuite/17_intro/headers/c++2017/all_no_exceptions.cc: Removed.
* testsuite/17_intro/headers/c++2017/all_no_rtti.cc: Removed.
* testsuite/17_intro/headers/c++2017/all_pedantic_errors.cc: Removed.
* testsuite/17_intro/headers/c++2017/charset.cc: Removed.
* testsuite/17_intro/headers/c++2017/operator_names.cc: Removed.
* testsuite/17_intro/headers/c++2017/stdc++.cc: Removed.
* testsuite/17_intro/headers/c++2017/stdc++_multiple_inclusion.cc: Removed.
* testsuite/17_intro/headers/c++2020/all_attributes.cc: Removed.
* testsuite/17_intro/headers/c++2020/all_no_exceptions.cc: Removed.
* testsuite/17_intro/headers/c++2020/all_no_rtti.cc: Removed.
* testsuite/17_intro/headers/c++2020/all_pedantic_errors.cc: Removed.
* testsuite/17_intro/headers/c++2020/charset.cc: Removed.
* testsuite/17_intro/headers/c++2020/operator_names.cc: Removed.
* testsuite/17_intro/headers/c++2020/stdc++.cc: Removed.
* testsuite/17_intro/headers/c++2020/stdc++_multiple_inclusion.cc: Removed.
The r15-1857 change means that <type_traits> is included by <cmath> for
C++17 and up, which breaks code including <math.h> inside an extern "C"
block. Although doing that is not allowed by the C++ standard, there's
lots of existing code which incorrectly thinks it's a good idea and so
we try to support it.
libstdc++-v3/ChangeLog:
PR libstdc++/115797
* include/std/type_traits: Ensure "C++" language linkage.
* testsuite/17_intro/headers/c++2011/linkage.cc: Replace
dg-options with c++11 target selector.
We see
FAIL: 17_intro/headers/c++1998/all_attributes.cc (test for excess errors)
FAIL: 17_intro/headers/c++2011/all_attributes.cc (test for excess errors)
FAIL: 17_intro/headers/c++2014/all_attributes.cc (test for excess errors)
FAIL: 17_intro/headers/c++2017/all_attributes.cc (test for excess errors)
FAIL: 17_intro/headers/c++2020/all_attributes.cc (test for excess errors)
FAIL: 17_intro/names.cc -std=gnu++17 (test for excess errors)
on s390x-linux.
The first 5 are due to kernel-headers not using uglified attribute names,
where <asm/types.h> contains
__attribute__((packed, aligned(4)))
I've filed a downstream bugreport for this in
https://bugzilla.redhat.com/show_bug.cgi?id=2276084
(not really sure where to report kernel-headers issues upstream), while the
last one is due to <sys/ucontext.h> from glibc containing:
#ifdef __USE_MISC
# define __ctx(fld) fld
#else
# define __ctx(fld) __ ## fld
#endif
...
typedef union
{
double __ctx(d);
float __ctx(f);
} fpreg_t;
and g++ predefining -D_GNU_SOURCE which implies define __USE_MISC.
The following patch adds a workaround for this on the libstdc++ testsuite
side.
2024-04-22 Jakub Jelinek <jakub@redhat.com>
* testsuite/17_intro/names.cc (d, f): Undefine on s390*-linux*.
* testsuite/17_intro/headers/c++1998/all_attributes.cc (packed): Don't
define on s390.
* testsuite/17_intro/headers/c++2011/all_attributes.cc (packed):
Likewise.
* testsuite/17_intro/headers/c++2014/all_attributes.cc (packed):
Likewise.
* testsuite/17_intro/headers/c++2017/all_attributes.cc (packed):
Likewise.
* testsuite/17_intro/headers/c++2020/all_attributes.cc (packed):
Likewise.
This fails due to "u" being used in a system header.
FAIL: experimental/names.cc -std=gnu++17 (test for excess errors)
Excess errors:
/usr/include/sys/poll.h:77: error: expected unqualified-id before ';' token
/usr/include/sys/poll.h:77: error: expected ')' before ';' token
FAIL: experimental/names.cc -std=gnu++17 (test for excess errors)
Excess errors:
/usr/include/sys/poll.h:102: error: expected unqualified-id before ';' token
/usr/include/sys/poll.h:102: error: expected ')' before ';' token
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names.cc [_AIX]: Undefine "u".
The name __null_sentinel is defined as a macro by newlib, so we can't
use it as an identifier. That variable is not actually used by
libstdc++, it was added because P2728R6 proposes std::uc::null_sentinel.
Since we don't need it and it breaks bootstrap for newlib targets, just
remove it. A null sentinel can still be used by constructing a
_Null_sentinel_t object as needed, rather than having a named object of
that type predefined.
libstdc++-v3/ChangeLog:
* include/bits/unicode.h (__null_sentinel): Remove.
* testsuite/17_intro/names.cc: Add __null_sentinel.
Fix tests that are checking for an expected allocation plan. They are failing if
an allocation is taking place outside the test main.
libstdc++-v3/ChangeLog
* testsuite/util/replacement_memory_operators.h
(counter::scope): New, capture and reset counter count at construction and
restore it at destruction.
(counter::check_new): Add scope instantiation.
* testsuite/23_containers/unordered_map/96088.cc (main):
Add counter::scope instantiation.
* testsuite/23_containers/unordered_multimap/96088.cc (main): Likewise.
* testsuite/23_containers/unordered_multiset/96088.cc (main): Likewise.
* testsuite/23_containers/unordered_set/96088.cc (main): Likewise.
* testsuite/ext/malloc_allocator/deallocate_local.cc (main): Likewise.
* testsuite/ext/new_allocator/deallocate_local.cc (main): Likewise.
* testsuite/ext/throw_allocator/deallocate_local.cc (main): Likewise.
* testsuite/ext/pool_allocator/allocate_chunk.cc (started): New global.
(operator new(size_t)): Check started.
(main): Set/Unset started.
* testsuite/17_intro/no_library_allocation.cc: New test case.
AIX <sys/thread.h> defines struct tstate with non-reserved names, so
adjust the 17_intro/names.cc test. It also defines struct user, which
conflicts with namespace user in some tests.
Replacing the global operator new doesn't work on AIX the same way as it
does for ELF, so skip some tests that depend on replacing it.
Add missing DG directives to synchronized_value test so it doesn't run
for the single-threaded AIX multilib.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names.cc [_AIX]: Do not define policy.
* testsuite/19_diagnostics/error_code/cons/lwg3629.cc: Rename
namespace to avoid clashing with libc struct.
* testsuite/19_diagnostics/error_condition/cons/lwg3629.cc:
Likewise.
* testsuite/23_containers/unordered_map/96088.cc: Skip on AIX.
* testsuite/23_containers/unordered_multimap/96088.cc: Likewise.
* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
* testsuite/23_containers/unordered_set/96088.cc: Likewise.
* testsuite/experimental/synchronized_value.cc: Require gthreads
and add missing option for pthreads targets.
This test detects redefinitions by compiling stdc++.h and <version>, by
disabling the system_header pragma on the latter, to allow warnings in
it. Thanks Patrick Palka for the suggestion.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/versionconflict.cc: New test.
* include/std/version: Allow disabling the system_header pragma
via _GLIBCXX_TESTING_SYSHDR.
The '#define func' added in 2021, to test that system headers don't
violate the user namespace, exposes such a bug in the vxworks sysLib.h
header, so add yet another such annotated workaround.
for libstdc++-v3/ChangeLog
* testsuite/17_intro/names.cc: Undef func on vxworks >= 7 in
kernel mode.
The https://github.com/oneapi-src/oneTBB/pull/833 fix is needed for TBB
headers to avoid an error with GCC 13. The new names_pstl.cc test needs
to check effective target tbb_backend so that it's UNSUPPORTED on
systems without fixed headers.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names_pstl.cc: Require et tbb_backend.
The non-reserved names 'val' and 'dest' were being used in our headers
but haven't been added to the 17_intro/names.cc test. That's because
they are used by <asm-generic/posix_types.h> and <netinet/tcp.h>
respecitvely on glibc-based systems.
libstdc++-v3/ChangeLog:
* include/bits/fs_ops.h (create_directory): Use reserved name
for parameter.
* include/bits/ranges_algo.h (__contains_subrange_fn):
Likewise.
* include/bits/regex_automaton.h (_State_base::_M_print):
Likewise.
* include/bits/regex_automaton.tcc(_State_base::_M_print):
Likewise.
* include/bits/regex_scanner.tcc(_Scanner::_M_print): Likewise.
* include/experimental/bits/fs_ops.h (create_directory):
Likewise.
* include/std/mutex (timed_mutex::_M_clocklock): Likewise.
(recursive_timed_mutex:_M_clocklock): Likewise.
* include/std/tuple (basic_common_reference): Likewise.
* libsupc++/cxxabi_init_exception.h
(__cxa_init_primary_exception): Likewise.
* testsuite/17_intro/names.cc: Add checks.
On gcc112 which has glibc 2.17 I've noticed
FAIL: 17_intro/names.cc (test for excess errors)
FAIL: experimental/names.cc (test for excess errors)
These are because glibc < 2.19 used __unused as field member of various structs,
including mcontext_t in sys/ucontext.h on ppc64le.
This was changed in glibc with
https://gcc.gnu.org/pipermail/libc-alpha/2013-November/045766.html
names.cc even has
#ifdef __GLIBC_PREREQ
#if ! __GLIBC_PREREQ(2, 19)
// Glibc defines this prior to 2.19
#undef __unused
#endif
#endif
for it, but it doesn't work. The reason is that __GLIBC_PREREQ is defined in
<features.h> but nothing included that header before this spot (it is included later
from bits/stdc++.h).
The following patch on Linux/Hurd conditionally includes features.h to get
the needed macros before deciding if __unused should be undefined or not.
If needed, I could use __GLIBC_PREREQ then but would need to check if it is
defined and between 1996 and 1999 it wasn't.
2023-01-27 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/108568
* testsuite/17_intro/names.cc (__unused): For linux or GNU hurd
include features.h if present and then check __GLIBC__ and
__GLIBC_MINOR__ macros for glibc prior to 2.19, instead of testing
__GLIBC_PREREQ which isn't defined yet.
Clang now defines an __is_unsigned built-in, and Windows defines an
_Out_ macro. Replace uses of those as identifiers.
There might also be a problem with __is_signed, which we use in several
places.
libstdc++-v3/ChangeLog:
* include/std/chrono (hh_mm_ss): Rename __is_unsigned member to
_S_is_unsigned.
* include/std/format (basic_format_context): Rename _Out_
template parameter to _Out2.
* testsuite/17_intro/names.cc: Add Windows SAL annotation
macros.
This test was recently modified to check that the library doesn't use
__unused anywhere, because that's a macro in newlib. But it's also a
macro in old versions of glibc, so the test now fails for those targets.
Disable that check for those targets as well as for newlib.
libstdc++-v3/ChangeLog:
PR libstdc++/107979
* testsuite/17_intro/names.cc: Do not check __unused on old
Glibc versions.
These names (and __unused) are defined as macros by newlib.
libstdc++-v3/ChangeLog:
* include/std/format: Rename all variables called __used or
__packed.
* testsuite/17_intro/badnames.cc: Add no_pch options.
* testsuite/17_intro/names.cc: Check __packed, __unused and
__used.
When linking with a static library, the linker seems to discard a
constituent .o object (including its global initializers) if nothing
defined in the object is referenced by the program (unless e.g.
--whole-archive is used). This behavior breaks iostream with static
libstdc++.a (on systems that support init priorities) because we define
the global initializer for the standard stream objects in a separate TU
(ios_init.cc) from the stream object definitions (globals_io.cc).
This patch fixes this by moving the stream initialization object into
the same TU that defines the stream objects, so that any use of the
streams prevents the linker from discarding this global initializer.
PR libstdc++/107701
libstdc++-v3/ChangeLog:
* include/std/iostream (__ioinit): Adjust comment.
* src/c++98/globals_io.cc: Include "io_base_init.h" here
instead of ...
* src/c++98/ios_init.cc: ... here.
* src/c++98/ios_base_init.h (__ioinit): More comments.
* testsuite/17_intro/static.cc: dg-do run instead of just link.
PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/103626
* testsuite/17_intro/headers/c++1998/stdc++.cc [!__STDC_HOSTED__]:
Do not include C headers that aren't valid for freestanding.
* testsuite/17_intro/tag_type_explicit_ctor.cc [!__STDC_HOSTED__]:
Do not test tag types that aren't defined for freestanding.
* testsuite/18_support/headers/cstdlib/functions_std.cc: Do not
check for std::getenv and std::system for freestanding.
* testsuite/17_intro/using_namespace_std_exp_neg.cc [!__STDC_HOSTED__]:
Do not test hosted parts of the standard library.
* testsuite/17_intro/using_namespace_std_tr1_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/members/rebind_alloc.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc [!HOSTED]:
Likewise.
* testsuite/20_util/headers/bitset/synopsis.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/pointer_traits/requirements/typedefs.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/tuple/cons/deduction.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/25_algorithms/move/93872.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/std/ranges/adaptors/100577.cc [!__STDC_HOSTED__]: Likewise.
Add a simpler definition of std::__detected_or using concepts. This
also replaces the __detector::value_t member which should have been using
a reserved name.
Use __detected_or in pointer_traits.
libstdc++-v3/ChangeLog:
* include/bits/alloc_traits.h (allocator_traits::is_always_equal):
Only instantiate is_empty if needed.
* include/bits/ptr_traits.h (__ptr_traits_impl::difference_type)
(__ptr_traits_impl::rebind): Use __detected_or.
* include/experimental/type_traits (is_same_v): Add a partial
specialization instead of instantiating the std::is_same class
template.
(detected_t): Redefine in terms of detected_or_t.
(is_detected, is_detected_v): Redefine in terms of detected_t.
* include/std/type_traits [__cpp_concepts] (__detected_or): Add
new definition using concepts.
(__detector::value_t): Rename to __is_detected.
* testsuite/17_intro/names.cc: Check value_t isn't used.
This fixes a test failure due to a non-reserved name in an AIX system
header (included via <pthread.h>). That name clashes with one of the
names we check our own headers for, so skip checking that name on AIX.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names.cc (func): Undef on AIX.
libstdc++-v3/ChangeLog:
* include/bits/regex_compiler.tcc (_Compiler::_M_match_token):
Use reserved name for parameter.
* testsuite/17_intro/names.cc: Check "token".
The <cxxx> headers for the C library are not under our control, so we
can't prevent them from including <unistd.h>. Change the PR 49745 test
to only include the C++ library headers, not the <cxxx> ones.
To ensure <bits/stdc++.h> isn't included automatically we need to use
no_pch to disable PCH.
libstdc++-v3/ChangeLog:
PR libstdc++/100117
* testsuite/17_intro/headers/c++1998/49745.cc: Explicitly list
all C++ headers instead of including <bits/stdc++.h>
17_intro/names.cc and experimental/names.cc currently FAIL on Solaris
FAIL: 17_intro/names.cc (test for excess errors)
FAIL: experimental/names.cc (test for excess errors)
Excess errors:
/usr/include/sys/timespec_util.h:22: error: expected ')' before ';' token
/usr/include/stdlib.h:157: error: expected unqualified-id before '[' token
/usr/include/stdlib.h:157: error: expected ')' before '[' token
<sys/timespec_util.h> has
extern int timespeccompare(const struct timespec *l, const struct timespec *r);
while <stdlib.h> has
typedef struct drand48_data {
unsigned int _initialised;
unsigned short int x[3];
unsigned short int a[3];
unsigned int c;
unsigned short lastx[3];
} drand48_data;
both of which are broken by defining r resp. x to ( in the testcase.
Fixed by undoing the defines. Tested on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.
2021-10-20 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
libstdc++-v3:
* testsuite/17_intro/names.cc [__sun__] (r, x): Undef.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names.cc: Undefine some more names used
by Solaris system headers.
The Windows CRT headers define structs with members called f, x, y etc
so don't check those. There are also lots of unnecessary function
parameters in mingw headers using non-reserved names, e.g.
<time.h> uses p and z as parameters of mingw_gettimeofday
<inttypes.h> uses j as a parameter of imaxabs
<pthread.h> uses l, o and func as parameter names
Those should be fixed in the headers instead.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* testsuite/17_intro/names.cc: Adjust for Windows.
I meant to undef the names that clash with newlib headers for newlib,
but I only undef'd them for non-newlib targets. This means they still
cause errors for newlib, and aren't tested for other targets.
This fixes the test to check those names for non-newlib targets, and to
undef them to avoid errors for newlib.
libstdc++-v3/ChangeLog:
PR libstdc++/97088
* testsuite/17_intro/names.cc: Fix #if condition for names used
by newlib headers.
Conditionally #undef some more names that are used in system headers.
libstdc++-v3/ChangeLog:
PR libstdc++/97088
* testsuite/17_intro/names.cc: Undef more names for newlib and
also for arm-none-linux-gnueabi.
* testsuite/experimental/names.cc: Disable PCH.
This test has no -std option so when the testsuite is run with
-std=gnu++20 or later, this test will use that. The recent addition of
no_unique_address will cause it to FAIL, because that's a reserved word
after C++17. Add an explicit option, so that this test alays uses
exactly C++17.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/headers/c++2017/all_attributes.cc: Add
-std=gnu++17 option.
The no_unique_address attribute is not a reserved name until C++20, so
to use it in C++11/14/17 modes we should use the __no_unique_address_
form. We already use that form when using the attribute, but not in the
__has_cpp_attribute check.
libstdc++-v3/ChangeLog:
PR libstdc++/101055
* include/std/tuple: Use reserved form of attribute name.
* testsuite/17_intro/headers/c++2011/all_attributes.cc: Add
check for no_unique_address.
* testsuite/17_intro/headers/c++2014/all_attributes.cc:
Likewise.
* testsuite/17_intro/headers/c++2017/all_attributes.cc:
Likewise.