Commit graph

14226 commits

Author SHA1 Message Date
GCC Administrator
08d0d17bef Daily bump. 2023-05-11 00:16:33 +00:00
François Dumont
5476c91428 libstdc++: [_Hashtable] Implement several small methods implicitly inline
Make implementation of 3 simple _Hashtable methods implicitly inline.

Avoid usage of const_iterator abstraction within _Hashtable implementation.

Replace several usages of __node_type* with expected __node_ptr.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h
	(_NodeBuilder<>::_S_build): Use __node_ptr.
	(_ReuseOrAllocNode<>): Use __node_ptr in place of __node_type*.
	(_AllocNode<>): Likewise.
	(_Equality<>::_M_equal): Remove const_iterator usages. Only preserved
	to call std::is_permutation in the non-unique key implementation.
	* include/bits/hashtable.h (_Hashtable<>::_M_update_begin()): Capture
	_M_begin() once.
	(_Hashtable<>::_M_bucket_begin(size_type)): Implement implicitly inline.
	(_Hashtable<>::_M_insert_bucket_begin): Likewise.
	(_Hashtable<>::_M_remove_bucket_begin): Likewise.
	(_Hashtable<>::_M_compute_hash_code): Use __node_ptr rather than
	const_iterator.
	(_Hashtable<>::find): Likewise.
	(_Hashtable<>::_M_emplace): Likewise.
	(_Hashtable<>::_M_insert_unique): Likewise.
2023-05-10 18:40:05 +02:00
GCC Administrator
35e324da03 Daily bump. 2023-05-10 00:17:49 +00:00
Jonathan Wakely
7bd251ca75 libstdc++: Fix <chrono> pretty printers and add tests
This fixes a couple of errors in the printers for chrono types, and adds
tests to ensure they keep working.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdChronoDurationPrinter):
	Print floating-point durations correctly.
	(StdChronoTimePointPrinter): Support printing only the value,
	not the type name. Uncomment handling for known clocks.
	(StdChronoZonedTimePrinter): Remove type names from output.
	(StdChronoCalendarPrinter): Fix hh_mm_ss member access.
	(StdChronoTimeZonePrinter): Add equals sign to output.
	* testsuite/libstdc++-prettyprinters/chrono.cc: New test.
2023-05-09 20:36:56 +01:00
GCC Administrator
2ab31cde21 Daily bump. 2023-05-06 00:16:37 +00:00
Alexandre Oliva
e383fc69d2 [libstdc++] [testsuite] xfail double-prec from_chars for ldbl
When long double is wider than double, but from_chars is implemented
in terms of double, tests that involve the full precision of long
double are expected to fail.  Mark them as such on aarch64-*-vxworks.


for  libstdc++-v3/ChangeLog

	* testsuite/20_util/from_chars/4.cc: Skip long double test06
	on aarch64-vxworks.
	* testsuite/20_util/to_chars/long_double.cc: Xfail run on
	aarch64-vxworks.
2023-05-05 08:28:41 -03:00
GCC Administrator
fde093b764 Daily bump. 2023-05-05 00:16:36 +00:00
Jonathan Wakely
2eadfb5c7e libstdc++: Document new library version in manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/abi.xml (abi.versioning.history): Document
	libstdc++.so.6.0.32 and GLIBCXX_3.4.32 version.
	* doc/html/manual/abi.html: Regenerate.
2023-05-04 12:38:10 +01:00
Florian Weimer
9cb3f25460 libstdc++: Mention recent libgcc_s symbol versions in manual
GCC_11.0 is an aarch64-specific outlier.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/abi.xml (abi.versioning.history): Add
	GCC_7.0.0, GCC_9.0.0, GCC_11.0, GCC_12.0.0, GCC_13.0.0 for
	libgcc_s.
2023-05-04 12:38:10 +01:00
GCC Administrator
257df67609 Daily bump. 2023-05-04 00:17:29 +00:00
Jakub Jelinek
b51e2fd65e libstdc++: Fix up abi.exp FAILs on powerpc64le-linux
This is an ABI problem on powerpc64le-linux, introduced in 13.1.
When libstdc++ is configured against old glibc, the
_ZSt10from_charsPKcS0_RDF128_St12chars_format@@GLIBCXX_3.4.31
_ZSt8to_charsPcS_DF128_@@GLIBCXX_3.4.31
_ZSt8to_charsPcS_DF128_St12chars_format@@GLIBCXX_3.4.31
_ZSt8to_charsPcS_DF128_St12chars_formati@@GLIBCXX_3.4.31
symbols are exported from the library, while when it is configured against
new enough glibc, those symbols aren't exported and we export instead
_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29
_ZSt8to_charsPcS_u9__ieee128@@GLIBCXX_IEEE128_3.4.29
_ZSt8to_charsPcS_u9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29
_ZSt8to_charsPcS_u9__ieee128St12chars_formati@@GLIBCXX_IEEE128_3.4.29
together with various other @@GLIBCXX_IEEE128_3.4.{29,30,31} and
@@CXXABI_IEEE128_1.3.13 symbols.  The idea was that those *IEEE128* symbol
versions (similarly to *LDBL* symbol versions) are optional (but if it
appears, all symbols from it up to the version of the library appears),
but the base appears always.
My _Float128 from_chars/to_chars changes unfortunately broke this.
I believe nothing really uses those symbols if libstdc++ has been
configured against old glibc, so if 13.1 wasn't already released, it might
be best to make sure they aren't exported on powerpc64le-linux.
But as they were exported, I think the best resolution for this ABI
difference is to add those 4 symbols as aliases to the
GLIBCXX_IEEE128_3.4.29 *u9__ieee128* symbols, which the following patch
does.

2023-05-03  Jakub Jelinek  <jakub@redhat.com>

	* src/c++17/floating_from_chars.cc
	(_ZSt10from_charsPKcS0_RDF128_St12chars_format): New alias to
	_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format.
	* src/c++17/floating_to_chars.cc (_ZSt8to_charsPcS_DF128_): New alias to
	_ZSt8to_charsPcS_u9__ieee128.
	(_ZSt8to_charsPcS_DF128_St12chars_format): New alias to
	_ZSt8to_charsPcS_u9__ieee128St12chars_format.
	(_ZSt8to_charsPcS_DF128_St12chars_formati): New alias to
	_ZSt8to_charsPcS_u9__ieee128St12chars_formati.
	* config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Updated.
2023-05-03 22:32:50 +02:00
Jakub Jelinek
a13ea34c6e libstdc++: Fix up abi.exp FAILs on powerpc64-linux
As discussed on IRC, my _Float128/_Float64x support changes broke
abi.exp testing on powerpc64-linux.

The
_ZTIDF128_@@CXXABI_1.3.14
_ZTIDF64x@@CXXABI_1.3.14
_ZTIPDF128_@@CXXABI_1.3.14
_ZTIPDF64x@@CXXABI_1.3.14
_ZTIPKDF128_@@CXXABI_1.3.14
_ZTIPKDF64x@@CXXABI_1.3.14
symbols only appear on powerpc64le-linux (both when building against
very old glibcs as well as contemporary glibcs), while they don't
appear on powerpc64-linux, because the latter never has _Float128 or
_Float64x support.

But we were using the same baseline_symbols.txt file for both
powerpc64-linux and powerpc64le-linux, even when it contained quite a lot
of stuff specific to the latter; but that was just the IEEE128 related
stuff that appears only when configured against not very old glibc.

The following patch keeps those exports as is and just splits the
config/abi/post/ files, copies the current one to powerpc64le-linux
unmodified and removes the above mentioned symbols plus all
GLIBCXX_IEEE128_3.4.{29,30,31} and CXXABI_IEEE128_1.3.13 symbols
from the powerpc64-linux version.

2023-05-03  Jakub Jelinek  <jakub@redhat.com>

	* configure.host (abi_baseline_pair): Use powerpc64le-linux-gnu
	rather than powerpc64-linux-gnu for powerpc64le*-linux*.
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Remove
	_ZTI*DF128_, _ZTI*DF64x symbols and symbols in
	GLIBCXX_IEEE128_3.4.{29,30,31} and CXXABI_IEEE128_1.3.13 symbol
	versions.
	* config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: New
	file.
2023-05-03 22:31:40 +02:00
Kefu Chai
cbf6c7a1d1 libstdc++: Set _M_string_length before calling _M_dispose() [PR109703]
This always sets _M_string_length in the constructor for ranges of input
iterators, such as stream iterators.

We copy from the source range to the local buffer, and then repeatedly
reallocate a larger one if necessary. When disposing the old buffer,
_M_is_local() is used to tell if the buffer is the local one or not (and
so must be deallocated). In addition to comparing the buffer address
with the local buffer, _M_is_local() has an optimization hint so that
the compiler knows that for a string using the local buffer, there is an
invariant that _M_string_length <= _S_local_capacity (added for PR109299
via r13-6915-gbf78b43873b0b7).  But we failed to set _M_string_length in
the constructor taking a pair of iterators, so the invariant might not
hold, and __builtin_unreachable() is reached. This causes UBsan errors,
and potentially misoptimization.

To ensure the invariant holds, _M_string_length is initialized to zero
before doing anything else, so that _M_is_local() doesn't see an
uninitialized value.

This issue only surfaces when constructing a string with a range of
input iterator, and the uninitialized _M_string_length happens to be
greater than _S_local_capacity, i.e., 15 for the std::string
specialization.

libstdc++-v3/ChangeLog:

	PR libstdc++/109703
	* include/bits/basic_string.h (basic_string(Iter, Iter, Alloc)):
	Initialize _M_string_length.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
2023-05-03 13:18:36 +01:00
GCC Administrator
d7cb9720ed Daily bump. 2023-05-03 00:17:11 +00:00
Jakub Jelinek
1d003da715 libstdc++: Regenerate baseline_symbols.txt files for Linux
The following patch regenerates the ABI files (I've only changed the
Linux files which were updated recently (last month)).

2023-05-02  Jakub Jelinek  <jakub@redhat.com>

	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Update.
	* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Update.
	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Update.
2023-05-02 19:27:54 +02:00
Jakub Jelinek
87de39e4c3 ibstdc++: Shut up -Wattribute-alias warning [PR109694]
I've followed what other files do, using attribute alias with not really
matching function type (after all, it isn't really possible when it is a
constructor), but seems I've missed it warns:
../../../../../libstdc++-v3/src/c++98/ios_init.cc:203:8: warning: ‘void std::ios_base_library_init()’ alias between functions of incompatible types ‘void()’ and ‘void
+(std::ios_base::Init::)()’ [-Wattribute-alias=]
  203 |   void ios_base_library_init (void)
      |        ^~~~~~~~~~~~~~~~~~~~~
../../../../../libstdc++-v3/src/c++98/ios_init.cc:78:3: note: aliased declaration here
   78 |   ios_base::Init::Init()
      |   ^~~~~~~~
The PR talks about clang++ warning there (which I think isn't really
supported, libstdc++ sources ought to be built by GCC), but it warns
when built with GCC too.

The following patch fixes it by doing what other libstdc++ sources do in
those cases.

2023-05-02  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/109694
	* src/c++98/ios_init.cc: Add #pragma GCC diagnostic ignored for
	-Wattribute-alias.
2023-05-02 10:58:19 +02:00
GCC Administrator
5020519574 Daily bump. 2023-04-29 00:16:48 +00:00
Jonathan Wakely
d711f8f81f libstdc++: Improve doxygen docs for <random>
Add @headerfile and @since tags. Add gamma_distribution to the correct
group (poisson distributions). Add a group for the sampling
distributions and add the missing definitions of their probability
functions. Add uniform_int_distribution back to the uniform
distributions group.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (gamma_distribution): Add to the right
	doxygen group.
	(discrete_distribution, piecewise_constant_distribution)
	(piecewise_linear_distribution): Create a new doxygen group and
	fix the incomplete doxygen comments.
	* include/bits/uniform_int_dist.h (uniform_int_distribution):
	Add to doxygen group.
2023-04-28 13:05:51 +01:00
Jonathan Wakely
30f6aace7f libstdc++: Minor fixes to doxygen comments
libstdc++-v3/ChangeLog:

	* include/bits/uses_allocator.h: Add missing @file comment.
	* include/bits/regex.tcc: Remove stray doxygen comments.
	* include/experimental/memory_resource: Likewise.
	* include/std/bit: Tweak doxygen @cond comments.
	* include/std/expected: Likewise.
	* include/std/numbers: Likewise.
2023-04-28 13:05:51 +01:00
Jonathan Wakely
975e8e836e libstdc++: Strip absolute paths from files shown in Doxygen docs
This avoids showing absolute paths from the expansion of
@srcdir@/libsupc++/ in the doxygen File List view.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (STRIP_FROM_PATH): Remove prefixes
	from header paths.
2023-04-28 13:05:50 +01:00
Jonathan Wakely
5c8b154c56 libstdc++: Simplify preprocessor/namespace nesting in <bits/move.h>
There's no good reason to conditionally close and reopen namespace std
within an #if block. Just include the <type_traits> header at the top
instead.

libstdc++-v3/ChangeLog:

	* include/bits/move.h: Simplify opening/closing namespace std.
2023-04-28 13:05:50 +01:00
Jakub Jelinek
9a41d2cdbc libstdc++: Another attempt to ensure g++ 13+ compiled programs enforce gcc 13.2+ libstdc++.so.6 [PR108969]
GCC used to emit an instance of an empty ios_base::Init class in
every TU which included <iostream> to ensure it is std::cout etc.
is initialized, but thanks to Patrick work on some targets (which have
init_priority attribute support) it is now initialized only inside of
libstdc++.so.6/libstdc++.a.

This causes a problem if people do something that has never been supported,
try to run GCC 13 compiled C++ code against GCC 12 or earlier
libstdc++.so.6 - std::cout etc. are then never initialized because code
including <iostream> expects the library to initialize it and the library
expects code including <iostream> to do that.

The following patch is second attempt to make this work cheaply as the
earlier attempt of aliasing the std::cout etc. symbols with another symbol
version didn't work out due to copy relocation breaking the aliases appart.

The patch forces just a _ZSt21ios_base_library_initv undefined symbol
into all *.o files which include <iostream> and while there is no runtime
relocation against that, it seems to enforce the right version of
libstdc++.so.6.  /home/jakub/src/gcc/obj08i/usr/local/ is the install
directory of trunk patched with this patch, /home/jakub/src/gcc/obj06/
is builddir of trunk without this patch, system g++ is GCC 12.1.1.
$ cat /tmp/hw.C
 #include <iostream>

int
main ()
{
  std::cout << "Hello, world!" << std::endl;
}
$ cd /home/jakub/src/gcc/obj08i/usr/local/bin
$ ./g++ -o /tmp/hw /tmp/hw.C
$ readelf -Wa /tmp/hw 2>/dev/null | grep initv
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZSt21ios_base_library_initv@GLIBCXX_3.4.32 (4)
    71: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZSt21ios_base_library_initv@GLIBCXX_3.4.32
$ /tmp/hw
/tmp/hw: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /tmp/hw)
$ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj08i/usr/local/lib64/ /tmp/hw
Hello, world!
$ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj06/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/ /tmp/hw
/tmp/hw: /home/jakub/src/gcc/obj06/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /tmp/hw)
$ g++ -o /tmp/hw /tmp/hw.C
$ /tmp/hw
Hello, world!
$ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj06/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/ /tmp/hw
Hello, world!
$ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj08i/usr/local/lib64/ /tmp/hw
Hello, world!

On sparc-sun-solaris2.11 one I've actually checked a version which had
defined(_GLIBCXX_SYMVER_SUN) next to defined(_GLIBCXX_SYMVER_GNU), but
init_priority attribute doesn't seem to be supported there and so I couldn't
actually test how this works there.  Using gas and Sun ld, Rainer, does one
need to use gas + gld for init_priority or something else?

2023-04-28  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/108969
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.32): Export
	_ZSt21ios_base_library_initv.
	* testsuite/util/testsuite_abi.cc (check_version): Add GLIBCXX_3.4.32
	symver and make it the latestp.
	* src/c++98/ios_init.cc (ios_base_library_init): New alias.
	* acinclude.m4 (libtool_VERSION): Change to 6:32:0.
	* include/std/iostream: If init_priority attribute is supported
	and _GLIBCXX_SYMVER_GNU, force undefined _ZSt21ios_base_library_initv
	symbol into the object.
	* configure: Regenerated.
2023-04-28 10:49:40 +02:00
GCC Administrator
32a98ccd23 Daily bump. 2023-04-28 00:16:50 +00:00
Jonathan Wakely
481281ccf4 libstdc++: Fix typos in doxygen comments
libstdc++-v3/ChangeLog:

	* include/bits/mofunc_impl.h: Fix typo in doxygen comment.
	* include/std/format: Likewise.
2023-04-27 11:28:40 +01:00
Jonathan Wakely
efa1276480 libstdc++: Remove obsolete options from Doxygen config
libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (FORMULA_TRANSPARENT, DOT_FONTNAME)
	(DOT_FONTSIZE, DOT_TRANSPARENT): Remove obsolete options.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
afa69618d1 libstdc++: Reduce Doxygen output for PDF
Including the header source code in the doxygen-generated PDF file makes
it too large, and causes pdflatex to run out of memory. If we only set
SOURCE_BROWSER=YES for the HTML docs then we won't include the sources
in the PDF file.

There are several macros defined for std::valarray that are only used to
generate repetitive code and then #undef'd. Those aren't useful in the
doxygen docs, especially the ones that reuse the same name in different
files. Omitting them avoids warnings about duplicate labels in the
refman.tex file.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (SOURCE_BROWSER): Only set to YES for
	HTML docs.
	* include/bits/gslice_array.h (_DEFINE_VALARRAY_OPERATOR): Omit
	from doxygen docs.
	* include/bits/indirect_array.h (_DEFINE_VALARRAY_OPERATOR):
	Likewise.
	* include/bits/mask_array.h (_DEFINE_VALARRAY_OPERATOR):
	Likewise.
	* include/bits/slice_array.h (_DEFINE_VALARRAY_OPERATOR):
	Likewise.
	* include/std/valarray (_DEFINE_VALARRAY_UNARY_OPERATOR)
	(_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT)
	(_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT)
	(_DEFINE_BINARY_OPERATOR): Likewise.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
afcf2b09b8 libstdc++: Improve doxygen docs for <memory_resource>
libstdc++-v3/ChangeLog:

	* include/bits/memory_resource.h: Improve doxygen comments.
	* include/std/memory_resource: Likewise.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
865869dc69 libstdc++: Add @headerfile and @since to doxygen comments [PR40380]
libstdc++-v3/ChangeLog:

	PR libstdc++/40380
	* include/bits/basic_string.h: Improve doxygen comments.
	* include/bits/cow_string.h: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/fs_dir.h: Likewise.
	* include/bits/fs_path.h: Likewise.
	* include/bits/quoted_string.h: Likewise.
	* include/bits/stl_bvector.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/std/filesystem: Likewise.
	* include/std/iomanip: Likewise.
2023-04-27 11:28:39 +01:00
Jonathan Wakely
f9412cedd6 libstdc++: Make std::random_device throw std::system_error [PR105081]
This changes std::random_device constructors to throw std::system_error
(with EINVAL as the error code) when the constructor argument is
invalid. We can also throw std::system_error when read(2) fails so that
the exception includes the additional information provided by errno.

As noted in the PR, this is consistent with libc++, and doesn't break
any existing code which catches std::runtime_error, because those
handlers will still catch std::system_error.

libstdc++-v3/ChangeLog:

	PR libstdc++/105081
	* src/c++11/random.cc (__throw_syserr): New function.
	(random_device::_M_init, random_device::_M_init_pretr1): Use new
	function for bad tokens.
	(random_device::_M_getval): Use new function for read errors.
	* testsuite/util/testsuite_random.h (random_device_available):
	Change catch handler to use std::system_error.
2023-04-27 11:28:39 +01:00
GCC Administrator
aeaf942699 Daily bump. 2023-04-25 00:17:46 +00:00
Patrick Palka
83470a5cd4 libstdc++: Fix __max_diff_type::operator>>= for negative values
This patch fixes sign bit propagation when right-shifting a negative
__max_diff_type value by more than one, a bug that our existing test
coverage didn't expose until r14-159-g03cebd304955a6 fixed the front
end's 'signed typedef-name' handling that the test relies on (which is
a non-standard extension to the language grammar).

libstdc++-v3/ChangeLog:

	* include/bits/max_size_type.h (__max_diff_type::operator>>=):
	Fix propagation of sign bit.
	* testsuite/std/ranges/iota/max_size_type.cc: Avoid using the
	non-standard 'signed typedef-name'.  Add some compile-time tests
	for right-shifting a negative __max_diff_type value by more than
	one.
2023-04-24 13:39:54 -04:00
GCC Administrator
cf0d9dbc09 Daily bump. 2023-04-20 00:17:12 +00:00
Patrick Palka
58b7dbf865 c++: Define built-in for std::tuple_element [PR100157]
This adds a new built-in to replace the recursive class template
instantiations done by traits such as std::tuple_element and
std::variant_alternative.  The purpose is to select the Nth type from a
list of types, e.g. __type_pack_element<1, char, int, float> is int.
We implement it as a special kind of TRAIT_TYPE.

For a pathological example tuple_element_t<1000, tuple<2000 types...>>
the compilation time is reduced by more than 90% and the memory used by
the compiler is reduced by 97%.  In realistic examples the gains will be
much smaller, but still relevant.

Unlike the other built-in traits, __type_pack_element uses template-id
syntax instead of call syntax and is SFINAE-enabled, matching Clang's
implementation.  And like the other built-in traits, it's not mangleable
so we can't use it directly in function signatures.

N.B. Clang seems to implement __type_pack_element as a first-class
template that can e.g. be used as a template-template argument.  For
simplicity we implement it in a more ad-hoc way.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

	PR c++/100157

gcc/cp/ChangeLog:

	* cp-trait.def (TYPE_PACK_ELEMENT): Define.
	* cp-tree.h (finish_trait_type): Add complain parameter.
	* cxx-pretty-print.cc (pp_cxx_trait): Handle
	CPTK_TYPE_PACK_ELEMENT.
	* parser.cc (cp_parser_constant_expression): Document default
	arguments.
	(cp_parser_trait): Handle CPTK_TYPE_PACK_ELEMENT.  Pass
	tf_warning_or_error to finish_trait_type.
	* pt.cc (tsubst) <case TRAIT_TYPE>: Handle non-type first
	argument.  Pass complain to finish_trait_type.
	* semantics.cc (finish_type_pack_element): Define.
	(finish_trait_type): Add complain parameter.  Handle
	CPTK_TYPE_PACK_ELEMENT.
	* tree.cc (strip_typedefs): Handle non-type first argument.
	Pass tf_warning_or_error to finish_trait_type.
	* typeck.cc (structural_comptypes) <case TRAIT_TYPE>: Use
	cp_tree_equal instead of same_type_p for the first argument.

libstdc++-v3/ChangeLog:

	* include/bits/utility.h (_Nth_type): Conditionally define in
	terms of __type_pack_element if available.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Prune
	additional errors from the new built-in.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/type_pack_element1.C: New test.
	* g++.dg/ext/type_pack_element2.C: New test.
	* g++.dg/ext/type_pack_element3.C: New test.
2023-04-19 15:36:34 -04:00
Jonathan Wakely
fac24d43e6 Revert "libstdc++: Export global iostreams with GLIBCXX_3.4.31 symver [PR108969]"
This reverts commit b7c54e3f48.

libstdc++-v3/ChangeLog:

	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt:
	* config/abi/post/i486-linux-gnu/baseline_symbols.txt:
	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt:
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt:
	* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt:
	* config/abi/pre/gnu.ver:
	* src/Makefile.am:
	* src/Makefile.in:
	* src/c++98/Makefile.am:
	* src/c++98/Makefile.in:
	* src/c++98/globals_io.cc (defined):
	(_GLIBCXX_IO_GLOBAL):
2023-04-19 13:18:12 +01:00
Jonathan Wakely
a6e4b81b12 Revert "libstdc++: Fix preprocessor condition in linker script [PR108969]"
This reverts commit 6067ae4557.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver:
2023-04-19 13:18:12 +01:00
GCC Administrator
d5cd3eada4 Daily bump. 2023-04-19 00:17:36 +00:00
Jonathan Wakely
b153f4e4ca libstdc++: Adjust uses of null pointer constants in docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/extensions.xml: Fix example to declare and
	qualify std::free, and use NULL instead of 0.
	* doc/html/manual/ext_demangling.html: Regenerate.
	* libsupc++/cxxabi.h: Adjust doxygen comments.
2023-04-19 00:13:02 +01:00
Jonathan Wakely
6067ae4557 libstdc++: Fix preprocessor condition in linker script [PR108969]
The linker script is preprocessed with $(top_builddir)/config.h not the
include/$target/bits/c++config.h version, which means that configure
macros do not have the _GLIBCXX_ prefix yet.

The _GLIBCXX_SYMVER_GNU and _GLIBCXX_SHARED checks are redundant,
because the gnu.ver file is only used for _GLIBCXX_SYMVER_GNU and the
linker script is only used for the shared library. Remove those.

libstdc++-v3/ChangeLog:

	PR libstdc++/108969
	* config/abi/pre/gnu.ver: Fix preprocessor condition.
2023-04-18 17:28:29 +01:00
Jonathan Wakely
b7c54e3f48 libstdc++: Export global iostreams with GLIBCXX_3.4.31 symver [PR108969]
Since GCC 13 the global iostream objects are only initialized once in
libstdc++, and not by a std::ios::Init object in every translation unit
that includes <iostream>. To avoid using uninitialized streams defined
in an older libstdc++.so, translation units using the global iostreams
should depend on the GLIBCXX_3.4.31 symver.

Define std::cin as std::__io::cin and then export it as
std::cin@@GLIBCXX_3.4.31 so that references to std::cin bind to the new
symver. Also export it as @GLIBCXX_3.4 for backwards compatibility

libstdc++-v3/ChangeLog:

	PR libstdc++/108969
	* src/Makefile.am: Move globals_io.cc to here.
	* src/Makefile.in: Regenerate.
	* src/c++98/Makefile.am: Remove globals_io.cc from here.
	* src/c++98/Makefile.in: Regenerate.
	* src/c++98/globals_io.cc [_GLIBCXX_SYMVER_GNU] (cin): Adjust
	symbol name and then export with GLIBCXX_3.4.31 symver.
	(cout, cerr, clog, wcin, wcout, wcerr, wclog): Likewise.
	* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/i486-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/m68k-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/s390x-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt:
	Regenerate.
	* config/abi/pre/gnu.ver: Add iostream objects to new symver.
2023-04-18 16:42:25 +01:00
Patrick Palka
cb5c71d16d libstdc++: Implement range_adaptor_closure from P2387R3 [PR108827]
PR libstdc++/108827

libstdc++-v3/ChangeLog:

	* include/bits/ranges_cmp.h (__cpp_lib_ranges): Bump value
	for C++23.
	* include/std/ranges (range_adaptor_closure): Define for C++23.
	* include/std/version (__cpp_lib_ranges): Bump value for
	C++23.
	* testsuite/std/ranges/version_c++23.cc: Bump expected value
	of __cpp_lib_ranges.
	* testsuite/std/ranges/range_adaptor_closure.cc: New test.
2023-04-18 07:21:13 -04:00
Patrick Palka
95525c5b8c libstdc++: Adding missing feature-test macros for C++23 ranges algos
This patch also renames __cpp_lib_fold to __cpp_lib_ranges_fold
as per the current draft standard.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__cpp_lib_ranges_contains):
	Define for C++23.
	(__cpp_lib_ranges_iota): Likewise.
	(__cpp_lib_ranges_find_last): Likewise.
	(__cpp_lib_fold): Rename to ...
	(__cpp_lib_ranges_fold): ... this.
	* include/std/version: As above.
	* testsuite/25_algorithms/fold_left/1.cc: Adjust after
	renaming __cpp_lib_fold.
	* testsuite/std/ranges/version_c++23.cc: Verify values
	of the above feature-test macros.
2023-04-18 07:21:09 -04:00
Patrick Palka
4ec4ceafcc libstdc++: Fix typo in views::as_const's operator() [PR109525]
PR libstdc++/109525

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::_AsConst::operator()): Add
	missing const to constant_range test.
	* testsuite/std/ranges/adaptors/as_const/1.cc (test02):
	Improve formatting.  Adjust expected type of v2.
	(test03): New test.
2023-04-18 07:21:07 -04:00
GCC Administrator
1aee19f9b5 Daily bump. 2023-04-15 00:16:36 +00:00
Patrick Palka
0d94c6df18 libstdc++: Implement P2278R4 "cbegin should always return a constant iterator"
This also implements the approved follow-up LWG issues 3765, 3766, 3769,
3770, 3811, 3850, 3853, 3862 and 3872.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (const_iterator_t): Define for C++23.
	(const_sentinel_t): Likewise.
	(range_const_reference_t): Likewise.
	(constant_range): Likewise.
	(__cust_access::__possibly_const_range): Likewise, replacing ...
	(__cust_access::__as_const): ... this.
	(__cust_access::_CBegin::operator()): Redefine for C++23 as per P2278R4.
	(__cust_access::_CEnd::operator()): Likewise.
	(__cust_access::_CRBegin::operator()): Likewise.
	(__cust_access::_CREnd::operator()): Likewise.
	(__cust_access::_CData::operator()): Likewise.
	* include/bits/ranges_util.h (ranges::__detail::__different_from):
	Make it an alias of std::__detail::__different_from.
	(view_interface::cbegin): Define for C++23.
	(view_interface::cend): Likewise.
	* include/bits/stl_iterator.h (__detail::__different_from): Define.
	(iter_const_reference_t): Define for C++23.
	(__detail::__constant_iterator): Likewise.
	(__detail::__is_const_iterator): Likewise.
	(__detail::__not_a_const_iterator): Likewise.
	(__detail::__iter_const_rvalue_reference_t): Likewise.
	(__detail::__basic_const_iter_cat):: Likewise.
	(const_iterator): Likewise.
	(__detail::__const_sentinel): Likewise.
	(const_sentinel): Likewise.
	(basic_const_iterator): Likewise.
	(common_type<basic_const_iterator<_Tp>, _Up>): Likewise.
	(common_type<_Up, basic_const_iterator<_Tp>>): Likewise.
	(common_type<basic_const_iterator<_Tp>, basic_const_iterator<Up>>):
	Likewise.
	(make_const_iterator): Define for C++23.
	(make_const_sentinel): Likewise.
	* include/std/ranges (__cpp_lib_ranges_as_const): Likewise.
	(as_const_view): Likewise.
	(enable_borrowed_range<as_const_view>): Likewise.
	(views::__detail::__is_ref_view): Likewise.
	(views::__detail::__can_is_const_view): Likewise.
	(views::_AsConst, views::as_const): Likewise.
	* include/std/span (span::const_iterator): Likewise.
	(span::const_reverse_iterator): Likewise.
	(span::cbegin): Likewise.
	(span::cend): Likewise.
	(span::crbegin): Likewise.
	(span::crend): Likewise.
	* include/std/version (__cpp_lib_ranges_as_const): Likewise.
	* testsuite/std/ranges/adaptors/join.cc (test06): Adjust to
	behave independently of C++20 vs C++23.
	* testsuite/std/ranges/version_c++23.cc: Verify value of
	__cpp_lib_ranges_as_const macro.
	* testsuite/24_iterators/const_iterator/1.cc: New test.
	* testsuite/std/ranges/adaptors/as_const/1.cc: New test.
2023-04-14 10:32:12 -04:00
Patrick Palka
2ab0d83e88 libstdc++: Move down definitions of ranges::cbegin/cend/cetc
This moves down the definitions of the range const-access CPOs to after
the definition of input_range in preparation for implementing P2278R4
which redefines these CPOs in a way that indirectly uses input_range.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (__cust_access::__as_const)
	(__cust_access::_CBegin, __cust::cbegin)
	(__cust_access::_CEnd, __cust::cend)
	(__cust_access::_CRBegin, __cust::crbegin)
	(__cust_access::_CREnd, __cust::crend)
	(__cust_access::_CData, __cust::cdata): Move down definitions to
	shortly after the definition of input_range.
2023-04-14 10:31:54 -04:00
Patrick Palka
7639bf34fa libstdc++: Implement ranges::fold_* from P2322R6
libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h: Include <optional> for C++23.
	(__cpp_lib_fold): Define for C++23.
	(in_value_result): Likewise.
	(__detail::__flipped): Likewise.
	(__detail::__indirectly_binary_left_foldable_impl): Likewise.
	(__detail::__indirectly_binary_left_foldable): Likewise.
	(___detail:__indirectly_binary_right_foldable): Likewise.
	(fold_left_with_iter_result): Likewise.
	(__fold_left_with_iter_fn, fold_left_with_iter): Likewise.
	(__fold_left_fn, fold_left): Likewise.
	(__fold_left_first_with_iter_fn, fold_left_first_with_iter):
	Likewise.
	(__fold_left_first_fn, fold_left_first): Likewise.
	(__fold_right_fn, fold_right): Likewise.
	(__fold_right_last_fn, fold_right_last): Likewise.
	* include/std/version (__cpp_lib_fold): Likewise.
	* testsuite/25_algorithms/fold_left/1.cc: New test.
	* testsuite/25_algorithms/fold_right/1.cc: New test.
2023-04-14 10:31:44 -04:00
Jonathan Wakely
6a9547f3ca libstdc++: Improve diagnostics for invalid std::format calls
Add a static_assert and a comment so that calling std::format for
unformattable argument types will now show:

/home/jwakely/gcc/13/include/c++/13.0.1/format:3563:22: error: static assertion failed: std::formatter must be specialized for each format arg
 3563 |       static_assert((is_default_constructible_v<formatter<_Args, _CharT>> && ...),
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and:

  140 |       formatter() = delete; // No std::formatter specialization for this type.

libstdc++-v3/ChangeLog:

	* include/std/format (formatter): Add comment to deleted default
	constructor of primary template.
	(_Checking_scanner): Add static_assert.
2023-04-14 11:58:39 +01:00
GCC Administrator
66c7257b67 Daily bump. 2023-04-13 00:16:48 +00:00
Jonathan Wakely
adda0e2887 libstdc++: Document libstdc++exp.a library for -fcontracts
libstdc++-v3/ChangeLog:

	* doc/xml/manual/using.xml: Document libstdc++exp.a library.
	* doc/html/*: Regenerate.
2023-04-12 23:26:35 +01:00
Jonathan Wakely
25264f6b3a libstdc++: Fix some AIX test failures
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.
2023-04-12 23:25:17 +01:00