Commit Graph

12314 Commits

Author SHA1 Message Date
Alexandre Oliva
3651c1b5c9 calibrate intervals to avoid zero in futures poll test
We get occasional failures of 30_threads/future/members/poll.cc
on some platforms whose high resolution clock doesn't have such a high
resolution; wait_for_0 ends up as 0, and then some asserts fail as
intervals measured as longer than zero are tested for less than
several times zero.

This patch adds some calibration in the iteration count to set a
measurable base time interval with some additional margin.


for  libstdc++-v3/ChangeLog

	* testsuite/30_threads/future/members/poll.cc: Calibrate
	iteration count.
2021-01-14 16:12:22 -03:00
François Dumont
05a30af3f2 libstdc++: Implement N3644 for _GLIBCXX_DEBUG iterators
libstdc++-v3/ChangeLog:

	PR libstdc++/98466
	* include/bits/hashtable_policy.h (_Node_iterator_base()): Set _M_cur to nullptr.
	(_Node_iterator()): Make default.
	(_Node_const_iterator()): Make default.
	* include/debug/macros.h (__glibcxx_check_erae_range_after): Add _M_singular
	iterator checks.
	* include/debug/safe_iterator.h
	(_GLIBCXX_DEBUG_VERIFY_OPERANDS): Accept if both iterator are value initialized.
	* include/debug/safe_local_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS):
	Likewise.
	* include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range): Add
	_M_singular checks on input iterators.
	* src/c++11/debug.cc (_Safe_iterator_base::_M_can_compare): Remove _M_singular
	checks.
	* testsuite/23_containers/deque/debug/98466.cc: New test.
	* testsuite/23_containers/unordered_map/debug/98466.cc: New test.
2021-01-14 19:23:54 +01:00
Jonathan Wakely
57a4f5e4ea libstdc++: Define function to throw filesystem_error [PR 98471]
Fix ordering problem on Windows targets where filesystem_error was used
before being defined.

libstdc++-v3/ChangeLog:

	PR libstdc++/98471
	* include/bits/fs_path.h (__throw_conversion_error): New
	function to throw or abort on character conversion errors.
	(__wstr_from_utf8): Move definition after filesystem_error has
	been defined. Use __throw_conversion_error.
	(path::_S_convert<_EcharT>): Use __throw_conversion_error.
	(path::_S_str_convert<_CharT, _Traits, _Allocator>): Likewise.
	(path::u8string): Likewise.
2021-01-14 16:26:30 +00:00
Jonathan Wakely
194a9d67be libstdc++: Update copyright dates on new files
The patch adding these files was approved in 2020 but it wasn't
committed until 2021, so the copyright years were not updated along with
the years in all the existing files.

libstdc++-v3/ChangeLog:

	* include/std/barrier: Update copyright years. Fix whitespace.
	* include/std/version: Fix whitespace.
	* testsuite/30_threads/barrier/1.cc: Update copyright years.
	* testsuite/30_threads/barrier/2.cc: Likewise.
	* testsuite/30_threads/barrier/arrive.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_drop.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_wait.cc: Likewise.
	* testsuite/30_threads/barrier/completion.cc: Likewise.
2021-01-14 14:25:10 +00:00
GCC Administrator
be0851b8e9 Daily bump. 2021-01-14 00:16:24 +00:00
Jonathan Wakely
f04e7e540e libstdc++: Fix typo in ChangeLog-2020 2021-01-13 11:02:13 +00:00
Jonathan Wakely
0db5f48848 libstdc++: Remove <debug/array> from Doxygen config
This header was removed recently, so Doxygen shouldn't try to process
it.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Remove include/debug/array.
2021-01-13 10:29:45 +00:00
GCC Administrator
366f86bd42 Daily bump. 2021-01-11 00:16:17 +00:00
David Edelsohn
4a1d7f7e20 libstdc++: Suppress more vstring testsuite warnings. [PR 98613]
PR c++/57111 - 57111 - Generalize -Wfree-nonheap-object to delete

can create false positive warnings for vstring _S_empty_rep.

This patch prunes the excess false positive warnings from two more
testcases.

libstdc++-v3/ChangeLog:

	PR libstdc++/98613
	* testsuite/ext/vstring/cons/moveable.cc: Suppress false positive
	warning.
	* testsuite/ext/vstring/modifiers/assign/move_assign.cc: Same.
2021-01-10 18:22:51 -05:00
GCC Administrator
bf5cbb9edf Daily bump. 2021-01-09 00:16:22 +00:00
Olivier Hainque
98546324c7 Tweak dg-prune-output regex for out-of-build-tree contexts
libstdc++-v3/

	* testsuite/20_util/bind/ref_neg.cc: Tweak the
	dg-prune-output regex for out-of-build-tree contexts.
2021-01-08 16:23:23 +00:00
GCC Administrator
7d187e4f6f Daily bump. 2021-01-08 00:16:23 +00:00
Thomas Rodgers
b7c3f201be libstdc++: Add support for C++20 barriers
Adds <barrier>

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in: Add new header.
	* include/Makefile.am (std_headers): likewise.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add new header.
	* include/std/barrier: New file.
	* include/std/version: Add __cpp_lib_barrier feature test macro.
	* testsuite/30_threads/barrier/1.cc: New test.
	* testsuite/30_threads/barrier/2.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_drop.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_wait.cc: Likewise.
	* testsuite/30_threads/barrier/arrive.cc: Likewise.
	* testsuite/30_threads/barrier/completion.cc: Likewise.
2021-01-07 12:52:37 -08:00
Patrick Palka
19f3c433cd libstdc++: Fix long double to_chars testcase [PR98384]
The testcase was failing to compile on some targets due to its use of
the non-standard functions nextupl and nextdownl.  This patch makes the
testcase instead use the C99 function nexttowardl in an equivalent way.

libstdc++-v3/ChangeLog:

	PR libstdc++/98384
	* testsuite/20_util/to_chars/long_double.cc: Use nexttowardl
	instead of the non-standard nextupl and nextdownl.
2021-01-07 12:41:14 -05:00
GCC Administrator
651b8a50a6 Daily bump. 2021-01-06 00:16:55 +00:00
Samuel Thibault
f56de3557f Update GNU/Hurd configure support
ChangeLog:

	* libtool.m4: Match gnu* along other GNU systems.
	* libgo/config/libtool.m4: Match gnu* along other GNU systems.
	* libgo/configure: Re-generate.

libffi/
	* configure: Re-generate.

libgomp/
	* configure: Re-generate.

gcc/

	* configure: Re-generate.

libatomic/

	* configure: Re-generate.

libbacktrace/

	* configure: Re-generate.

libcc1/

	* configure: Re-generate.

libgfortran/

	* configure: Re-generate.

libgomp/

	* configure: Re-generate.

libhsail-rt/

	* configure: Re-generate.

libitm/

	* configure: Re-generate.

libobjc/

	* configure: Re-generate.

liboffloadmic/

	* configure: Re-generate.
	* plugin/configure: Re-generate.

libphobos/

	* configure: Re-generate.

libquadmath/

	* configure: Re-generate.

libsanitizer/

	* configure: Re-generate.

libssp/

	* configure: Re-generate.

libstdc++-v3/

	* configure: Re-generate.

libvtv/

	* configure: Re-generate.

lto-plugin/

	* configure: Re-generate.

zlib/

	* configure: Re-generate.
2021-01-05 16:04:14 -07:00
Ed Smith-Rowland
ae1ada95fe Add <source_location> to the precompiled header.
2021-01-05  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* include/precompiled/stdc++.h: Add <source_location> to C++20 section.
2021-01-05 15:50:06 -05:00
Jakub Jelinek
99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
GCC Administrator
b6dd195aac Daily bump. 2021-01-02 00:16:24 +00:00
Jakub Jelinek
618e665a0f Rotate ChangeLog files - step 2 - remove 2020 entries from ChangeLog files.
Can't be committed together with the previous one due to the ChangeLog vs.
other files restrictions.
2021-01-01 17:30:04 +01:00
Jakub Jelinek
6e92696278 Rotate ChangeLog files - part 1 - add ChangeLog-2020.
2021-01-01  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/ada/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/cp/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/d/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/fortran/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/testsuite/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
libgfortran/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
libstdc++-v3/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
2021-01-01 17:27:52 +01:00
GCC Administrator
adfe99ad8f Daily bump. 2020-12-28 00:16:28 +00:00
Gerald Pfeifer
15b99a6b83 libstdc++: Update link to Arm ABI
libstdc++-v3:

2020-12-27  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/abi.xml: Update link to Arm ABI.
	* doc/html/manual/abi.html: Regenerate.
2020-12-27 21:25:32 +01:00
Gerald Pfeifer
0e283e2c9f libstdc++: Move Valgrind references to https
libstdc++-v3:

2020-12-27  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/debug.xml: Move Valgrind references to https.
	* doc/html/manual/debug.html: Regenerate.
2020-12-27 11:17:21 +01:00
GCC Administrator
521bc8e1b0 Daily bump. 2020-12-27 00:16:18 +00:00
Gerald Pfeifer
9d426e4dbc libstdc++: Update link to Intel/GNU compatibility paper
libstdc++-v3:

2020-12-26  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/abi.xml: Update link to Intel's compatibility
	with GNU compilers document.
	* doc/html/manual/abi.html: Regenerate.
2020-12-26 13:37:48 +01:00
GCC Administrator
5b4da2d9e1 Daily bump. 2020-12-26 00:16:19 +00:00
Gerald Pfeifer
a746898dff libstdc++: Update link to Java docs
libstdc++-v3:

2020-12-25  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/messages.xml: Update link to Java docs.
	* doc/html/manual/facets.html: Ditto.
2020-12-25 19:14:35 +01:00
Gerald Pfeifer
4ee8e5949a libstdc++: Convert three doxygen.nl links to https
libstdc++-v3:
2020-12-25  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/documentation_hacking.xml: Convert three links
	to doxygen.nl to https.
	* doc/html/manual/documentation_hacking.html: Regenerate.
2020-12-25 15:20:43 +01:00
GCC Administrator
85d8ebcfc2 Daily bump. 2020-12-24 00:16:26 +00:00
Olivier Hainque
eb81c997d8 Account for VxWorks headers in libstdc++ test on names
Undefine various macros unexpectedly defined by VxWorks headers.


for  libstdc++-v3/ChangeLog

	* testsuite/17_intro/names.cc: Account for VxWorks headers.
2020-12-23 20:27:36 -03:00
GCC Administrator
1a5e728a54 Daily bump. 2020-12-22 00:16:23 +00:00
Patrick Palka
6a31d47e27 libstdc++: Disable floating-point std::to_chars on unsupported targets
This patch conditionally disables the floating-point std::to_chars
implementation on targets whose float and double aren't IEEE binary32
and binary64, until a proper fallback can be added for such targets.
This fixes a bootstrap failure on non-IEEE-754 FP targets such as
vax-netbsdelf.

The new preprocessor tests in c++config that detect the binary32 and
binary64 formats were copied from gcc/testsuite/gcc.dg/float-exact-1.c.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_FLOAT_IS_IEEE_BINARY_32):
	Define this macro.
	(_GLIBCXX_DOUBLE_IS_IEEE_BINARY_64): Likewise.
	* include/std/charconv (to_chars): Use these macros to
	conditionally hide the overloads for floating-point types.
	* src/c++17/floating_to_chars.cc: Use the macros to
	conditionally disable this file.
	(floating_type_traits<float>): Remove redundant static assert.
	(floating_type_traits<double>): Likewise.
	* testsuite/20_util/to_chars/double.cc: Run this test only on
	ieee-floats effective targets.
	* testsuite/20_util/to_chars/float.cc: Likewise.
	* testsuite/20_util/to_chars/long_double.cc: Likewise.
	* testsuite/lib/libstdc++.exp
	(check_effective_target_ieee-floats): Define new proc for
	detecting whether float and double have the IEEE binary32 and
	binary64 formats.
2020-12-21 15:15:36 -05:00
GCC Administrator
108beb75da Daily bump. 2020-12-21 00:16:20 +00:00
Jonathan Wakely
3621a7bb57 libstdc++: Fix indentation in <semaphore>
libstdc++-v3/ChangeLog:

	* include/std/semaphore: Fix indentation.
2020-12-20 18:49:46 +00:00
GCC Administrator
b1a2242e24 Daily bump. 2020-12-19 00:16:31 +00:00
Patrick Palka
60cecb2b83 libstdc++: Fix mistake in PR98374 change [PR98377]
The #ifdef RADIXCHAR directive should be moved one line up so that it
also guards the outer if statement, or else when RADIXCHAR is not
defined the outer if statement will end up nonsensically guarding the
declaration of output_length_upper_bound a few lines below it.

libstdc++-v3/ChangeLog:

	PR libstdc++/98377
	* src/c++17/floating_to_chars.cc (__floating_to_chars_precision):
	Fix mistake.
2020-12-18 13:01:49 -05:00
Patrick Palka
22a7e82c20 libstdc++: Fix build failure on AArch64 ILP32 [PR98370]
This should fix a build failure on AArch64 ILP32 due to int32_t mapping
to long int instead of int on this platform, which causes type deduction
to fail in the below call to std::max as reported in the PR.

libstdc++-v3/ChangeLog:

	PR libstdc++/98370
	* src/c++17/floating_to_chars.cc (__floating_to_chars_shortest):
	Provide explicit template arguments to the call to std::max.
2020-12-18 11:52:24 -05:00
Patrick Palka
d7bab388b8 libstdc++: Fix build failure due to missing <langinfo.h> [PR98374]
This should fix a build failure on Windows which lacks <langinfo.h>,
from which we use nl_langinfo() to obtain the radix character of the
current locale.  (We can't use the more portable localeconv() from
<clocale> to obtain the radix character of the current locale here
because it's not thread-safe, unfortunately.)

This change means that on Windows and other such platforms, we'll just
always assume the radix character used by printf is '.' when formatting
a long double through it.

libstdc++-v3/ChangeLog:

	PR libstdc++/98374
	* src/c++17/floating_to_chars.cc: Guard include of <langinfo.h>
	with __has_include.
	(__floating_to_chars_precision) [!defined(RADIXCHAR)]: Don't
	attempt to obtain the radix character of the current locale,
	just assume it's '.'.
2020-12-18 11:52:17 -05:00
Patrick Palka
266d746475 libstdc++: Check FE_TONEAREST is defined before using it
We need to test that FE_TONEAREST is defined before we may use it along
with fegetround/fesetround to adjust the floating-point rounding mode.
This fixes a build failure with older versions of newlib.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc (from_chars_impl)
	[!defined(FE_TONEAREST)]: Don't adjust the rounding mode.
	* src/c++17/floating_to_chars.cc (__floating_to_chars_precision):
	Likewise.
2020-12-18 11:52:14 -05:00
Patrick Palka
ddb9c661c2 libstdc++: Import MSVC floating-point std::to_chars testcases
The testcases are imported almost verbatim, with the only change being
to the -double_nan and -float_nan testcases.  We expect these values to
be formatted as "-nan" instead of "-nan(ind)".

libstdc++-v3/ChangeLog:

	* testsuite/20_util/to_chars/double.cc: New test, consisting of
	testcases imported from the MSVC STL testsuite.
	* testsuite/20_util/to_chars/float.cc: Likewise.
2020-12-17 23:11:38 -05:00
Patrick Palka
3c57e69235 libstdc++: Add floating-point std::to_chars implementation
This implements the floating-point std::to_chars overloads for float,
double and long double.  We use the Ryu library to compute the shortest
round-trippable fixed and scientific forms for float, double and long
double.  We also use Ryu for performing explicit-precision fixed and
scientific formatting for float and double. For explicit-precision
formatting for long double we fall back to using printf.  Hexadecimal
formatting for float, double and long double is implemented from
scratch.

The supported long double binary formats are binary64, binary80 (x86
80-bit extended precision), binary128 and ibm128.

Much of the complexity of the implementation is in computing the exact
output length before handing it off to Ryu (which doesn't do bounds
checking).  In some cases it's hard to compute the output length
beforehand, so in these cases we instead compute an upper bound on the
output length and use a sufficiently-sized intermediate buffer only if
necessary.

Another source of complexity is in the general-with-precision formatting
mode, where we need to do zero-trimming of the string returned by Ryu,
and where we also take care to avoid having to format the number through
Ryu a second time when the general formatting mode resolves to fixed
(which we determine by doing a scientific formatting first and
inspecting the scientific exponent).  We avoid going through Ryu twice
by instead transforming the scientific form to the corresponding fixed
form via in-place string manipulation.

This implementation is non-conforming in a couple of ways:

1. For the shortest hexadecimal formatting, we currently follow the
   Microsoft implementation's decision to be consistent with the
   output of printf's '%a' specifier at the expense of sometimes not
   printing the shortest representation.  For example, the shortest hex
   form for the number 1.08p+0 is 2.1p-1, but we output the former
   instead of the latter, as does printf.

2. The Ryu routine generic_binary_to_decimal that we use for performing
   shortest formatting for large floating point types is implemented
   using the __int128 type, but some targets with a large long double
   type lack __int128 (e.g. i686), so we can't perform shortest
   formatting of long double on such targets through Ryu.  As a
   temporary stopgap this patch makes the long double to_chars overloads
   just dispatch to the double overloads on these targets, which means
   we lose precision in the output.  (We could potentially fix this by
   writing a specialized version of Ryu's generic_binary_to_decimal
   routine that uses uint64_t instead of __int128.)  [Though I wonder if
   there's a better way to work around the lack of __int128 on i686
   specifically?]

3. Our shortest formatting for __ibm128 doesn't guarantee the round-trip
   property if the difference between the high- and low-order exponent
   is large.  This is because we treat __ibm128 as if it has a
   contiguous 105-bit mantissa by merging the mantissas of the high-
   and low-order parts (using code extracted from glibc), so we
   potentially lose precision from the low-order part.  This seems to be
   consistent with how glibc printf formats __ibm128.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver: Add new exports.
	* include/std/charconv (to_chars): Declare the floating-point
	overloads for float, double and long double.
	* src/c++17/Makefile.am (sources): Add floating_to_chars.cc.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/floating_to_chars.cc: New file.
	(to_chars): Define for float, double and long double.
	* testsuite/20_util/to_chars/long_double.cc: New test.
2020-12-17 23:11:34 -05:00
Patrick Palka
5033506993 libstdc++: Apply modifications to our local copy of Ryu
This performs the following modifications to our local copy of Ryu in
order to make it more readily usable for our std::to_chars
implementation:

  * Remove all #includes
  * Remove copy_special_str routines
  * Adjust the exponent formatting to match printf
  * Remove some functions we're not going to use
  * Add an out-parameter to d2exp_buffered_n for the scientific exponent
  * Store the sign bit inside struct floating_decimal_[32|64]
  * Rename [df]2s_buffered_n and change their return type
  * Make generic_binary_to_decimal take the bit representation in parts

libstdc++-v3/ChangeLog:

	* src/c++17/ryu/common.h, src/c++17/ryu/d2fixed.c,
	src/c++17/ryu/d2fixed_full_table.h, src/c++17/ryu/d2s.c,
	src/c++17/ryu/d2s_intrinsics.h, src/c++17/ryu/f2s.c,
	src/c++17/ryu/f2s_intrinsics.h, src/c++17/ryu/generic_128.c:
	Apply local modifications.
2020-12-17 23:11:15 -05:00
Patrick Palka
e3f0eaa282 libstdc++: Import parts of the Ryu library
This imports the source files from the Ryu library that define
d2s_buffered_n, f2s_buffered_n, d2fixed_buffered_n, d2exp_buffered_n and
generic_binary_to_decimal, which we're going to use as the base of our
std::to_chars implementation.

libstdc++-v3/ChangeLog:

	* src/c++17/ryu/MERGE: New file.
	* src/c++17/ryu/common.h, src/c++17/ryu/d2fixed.c,
	src/c++17/ryu/d2fixed_full_table.h, src/c++17/ryu/d2s.c,
	src/c++17/ryu/d2s_full_table.h, src/c++17/ryu/d2s_intrinsics.h,
	src/c++17/ryu/digit_table.h, src/c++17/ryu/f2s.c,
	src/c++17/ryu/f2s_intrinsics.h, src/c++17/ryu/generic_128.c,
	src/c++17/ryu/generic_128.h, src/c++17/ryu/ryu_generic_128.h:
	Import these files from the Ryu library.
2020-12-17 23:11:12 -05:00
GCC Administrator
cd69e3d5cd Daily bump. 2020-12-18 00:16:30 +00:00
Jonathan Wakely
217d5beaff libstdc++: Test errno macros directly for all targets [PR 93151]
This applies the same changes to the djgpp and mingw versions of
error_constants.h as r11-6137 did for the generic version.

All of these constants are defined as macros by <errno.h> on these
targets, so we can just test the macro directly instead of checking for
it at configure time.

libstdc++-v3/ChangeLog:

	* config/os/djgpp/error_constants.h: Test POSIX errno macros
	directly, instead of corresponding _GLIBCXX_HAVE_EXXX macros.
	* config/os/mingw32-w64/error_constants.h: Likewise.
	* config/os/mingw32/error_constants.h: Likewise.
2020-12-17 16:19:20 +00:00
Jonathan Wakely
b2bc1bb6ca libstdc++: Fix condition for gthreads-timed effective-target
The refactoring in r11-5500 altered the condition for the gthreads-timed
test from #if to #ifdef. For some reason that macro is always defined,
rather than being defined to 1 or undefined like most of our autoconf
macros. That means the test always passes now, even for targets where
the macro is defined to 0 (specifically, Darwin). That causes some tests
to FAIL when they should have been UNSUPPORTED.

This restores the previous behaviour.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (check_v3_target_gthreads_timed):
	Fix condition for _GTHREAD_USE_MUTEX_TIMEDLOCK test.
2020-12-17 16:16:37 +00:00
Jonathan Wakely
9f9dbc8e09 libstdc++: Fix -Wunused warning
As noted in PR 66146 comment 35, there is a new warning in the new
std::call_once implementation.

libstdc++-v3/ChangeLog:

	* src/c++11/mutex.cc (std::once_flag::_M_finish): Add
	maybe_unused attribute to variable used in assertion.
2020-12-17 14:03:00 +00:00
Jonathan Wakely
8dc63f13f0 libstdc++: Fix preprocessor condition [PR 98344]
libstdc++-v3/ChangeLog:

	PR libstdc++/98344
	* include/bits/semaphore_base.h: Fix preprocessor condition.
2020-12-17 14:03:00 +00:00
Jonathan Wakely
8cdca5f9c7 libstdc++: Move std::hash<std:🧵:id> to <bits/std_thread.h>
This makes the hash function available without including the whole of
<thread>, which is needed for <barrier>.

libstdc++-v3/ChangeLog:

	* include/bits/std_thread.h (hash<thread::id>): Move here,
	from ...
	* include/std/thread (hash<thread::id>): ... here.
2020-12-17 14:03:00 +00:00
Jonathan Wakely
f5feee6adc libstdc++: Regenerate autoconf files
I forgot to regenerate these files in r11-6137.

libstdc++-v3/ChangeLog:

	* config.h.in: Regenerate.
	* configure: Regenerate.
2020-12-17 14:02:59 +00:00
GCC Administrator
eefe499fdf Daily bump. 2020-12-17 00:16:37 +00:00
Jonathan Wakely
7c1e7eed89 libstdc++: Add C++ runtime support for new 128-bit long double format
This adds support for the new __ieee128 long double format on
powerpc64le targets.

Most of the complexity comes from wanting a single libstdc++.so library
that contains the symbols needed by code compiled with both
-mabi=ibmlongdouble and -mabi=ieeelongdouble (and not forgetting
-mlong-double-64 as well!)

In a few places this just requires an extra overload, for example
std::from_chars has to be overloaded for both forms of long double.
That can be done in a single translation unit that defines overloads
for 'long double' and also '__ieee128', so that user code including
<charconv> will be able to link to a definition for either type of long
double. Those are the easy cases.

The difficult parts are (as for the std::string ABI transition) the I/O
and locale facets. In order to be able to write either form of long
double to an ostream such as std::cout we need the locale to contain a
std::num_put facet that can handle both forms. The same approach is
taken as was already done for supporting 64-bit long double and 128-bit
long double: adding extra overloads of do_put to the facet class. On
targets where the new long double code is enabled, the facets that are
registered in the locale at program startup have additional overloads so
that they can work with any long double type. Where this fails to work
is if user code installs its own facet, which will probably not have the
additional overloads and so will only be able to output one or the other
type. In practice the number of users expecting to be able to use their
own locale facets in code using a mix of -mabi=ibmlongdouble and
-mabi=ieeelongdouble is probably close to zero.

libstdc++-v3/ChangeLog:

	* Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver: Make patterns less greedy.
	* config/os/gnu-linux/ldbl-ieee128-extra.ver: New file with patterns
	for IEEE128 long double symbols.
	* configure: Regenerate.
	* configure.ac: Enable alternative 128-bit long double format on
	powerpc64*-*-linux*.
	* doc/Makefile.in: Regenerate.
	* fragment.am: Regenerate.
	* include/Makefile.am: Set _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT.
	* include/Makefile.in: Regenerate.
	* include/bits/c++config: Define inline namespace for new long
	double symbols. Don't define _GLIBCXX_USE_FLOAT128 when it's the
	same type as long double.
	* include/bits/locale_classes.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]
	(locale::_Impl::_M_init_extra_ldbl128): Declare new member function.
	* include/bits/locale_facets.h (_GLIBCXX_NUM_FACETS): Simplify by
	only counting narrow character facets.
	(_GLIBCXX_NUM_CXX11_FACETS): Likewise.
	(_GLIBCXX_NUM_LBDL_ALT128_FACETS): New.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (num_get::__do_get): Define
	vtable placeholder for __ibm128 long double type.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(num_get::__do_get): Declare vtable placeholder for __ibm128 long
	double type.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(num_put::__do_put): Likewise.
	* include/bits/locale_facets.tcc
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(num_get::__do_get, num_put::__do_put): Define.
	* include/bits/locale_facets_nonio.h
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(money_get::__do_get): Declare vtable placeholder for __ibm128 long
	double type.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(money_put::__do_put): Likewise.
	* include/bits/locale_facets_nonio.tcc
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(money_get::__do_get, money_put::__do_put): Define.
	* include/ext/numeric_traits.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]
	(__numeric_traits<__ibm128>, __numeric_traits<__ieee128>): Define.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.am: Add compatibility-ldbl-alt128.cc and
	compatibility-ldbl-alt128-cxx11.cc sources and recipes for objects.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++11/compatibility-ldbl-alt128-cxx11.cc: New file defining
	symbols using the old 128-bit long double format, for the cxx11 ABI.
	* src/c++11/compatibility-ldbl-alt128.cc: Likewise, for the
	gcc4-compatible ABI.
	* src/c++11/compatibility-ldbl-facets-aliases.h: New header for long
	double compat aliases.
	* src/c++11/cow-locale_init.cc: Add comment.
	* src/c++11/cxx11-locale-inst.cc: Define C and C_is_char
	unconditionally.
	* src/c++11/cxx11-wlocale-inst.cc: Add sanity check. Include
	locale-inst.cc directly, not via cxx11-locale-inst.cc.
	* src/c++11/locale-inst-monetary.h: New header for monetary
	category instantiations.
	* src/c++11/locale-inst-numeric.h: New header for numeric category
	instantiations.
	* src/c++11/locale-inst.cc: Include new headers for monetary,
	numeric, and long double definitions.
	* src/c++11/wlocale-inst.cc: Remove long double compat aliases that
	are defined in new header now.
	* src/c++17/Makefile.am: Use -mabi=ibmlongdouble for
	floating_from_chars.cc.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/floating_from_chars.cc (from_chars_impl): Add
	if-constexpr branch for __ieee128.
	(from_chars): Overload for __ieee128.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/c++98/locale_init.cc (num_facets): Adjust calculation.
	(locale::_Impl::_Impl(size_t)): Call _M_init_extra_ldbl128.
	* src/c++98/localename.cc (num_facets): Adjust calculation.
	(locale::_Impl::_Impl(const char*, size_t)): Call
	_M_init_extra_ldbl128.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/util/testsuite_abi.cc: Add new symbol versions.
	Allow new symbols to be added to GLIBCXX_IEEE128_3.4.29 and
	CXXABI_IEEE128_1.3.13 too.
	* testsuite/26_numerics/complex/abi_tag.cc: Add u9__ieee128 to
	regex matching expected symbols.
2020-12-16 23:25:01 +00:00
Jonathan Wakely
4d4f82959a libstdc++: Simplify built-in detection in <utility>
Now that GCC supports __has_builtin there is no need to test whether
it's defined, we can just use it unconditionally.

libstdc++-v3/ChangeLog:

	* include/std/utility: Use __has_builtin without checking if
	it's defined.
2020-12-16 19:25:09 +00:00
Jonathan Wakely
767537a8b0 libstdc++: Warn if __STRICT_ANSI has been undefined
Recent changes to use __int128 as an integer-like type in <ranges> and
to optimize std::uniform_int_distribution mean that the library relies
on __int128 more heavily than in the past.

The library expects that if __int128 is supported then either
__GLIBCXX_TYPE_INT_N_0 is defined (and we treat is like the standard
integer types), or __STRICT_ANSI__ is defined (and we need to add
special handling for __int128 as a non-standard integer type).

If users compile with -std=c++NN -U__STRICT_ANSI__ then it puts the
library into a broken and inconsistent state, where the compiler doesn't
define the __GLIBCXX_TYPE_INT_N_0 macro, but the library thinks it
doesn't need special handling for __int128. What the user should do is
compile with -std=gnu++NN instead.

This adds a warning if it appears that __int128 is supported but neither
__GLIBCXX_TYPE_INT_N_0 nor __STRICT_ANSI__ is defined.

libstdc++-v3/ChangeLog:

	* include/bits/c++config: Warn if __STRICT_ANSI__ state is
	inconsistent with __GLIBCXX_TYPE_INT_N_0.
2020-12-16 19:25:09 +00:00
Jonathan Wakely
96d9670e88 libstdc++: Only use __builtin_sprintf if supported [PR 96083]
Clang doesn't support __builtin_sprintf, so use std::sprintf instead.

libstdc++-v3/ChangeLog:

	PR libstdc++/96083
	* include/ext/throw_allocator.h: Use __has_builtin to check for
	__builtin_sprintf support, and use std::sprtinf if necessary.
2020-12-16 14:33:26 +00:00
Jonathan Wakely
ab9bd93271 libstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]
Currently the <experimental/random>, <experimental/source_location> and
<experimental/utility> headers can be included in C++98 and C++11 modes,
but gives errors. With this change they can be included, but define
nothing.

libstdc++-v3/ChangeLog:

	PR libstdc++/98319
	* include/experimental/random: Only define contents for C++14
	and later.
	* include/experimental/source_location: Likewise.
	* include/experimental/utility: Likewise.
	* testsuite/experimental/feat-lib-fund.cc: Include all LFTS
	headers that are present. Allow test to run for all modes.
2020-12-16 13:37:17 +00:00
Jonathan Wakely
3cee0c6562 libstdc++: Add performance test for atomic_flag [PR 46447]
This adds a test to compare the performance of std::atomic_flag with
similar operations on std::atomic_uchar and std::atomic_int.

libstdc++-v3/ChangeLog:

	PR libstdc++/46447
	* testsuite/performance/29_atomics/atomic_flag.cc: New test.
2020-12-16 13:36:02 +00:00
Jonathan Wakely
a2c2eec183 libstdc++: Test errno macros directly, not via autoconf [PR 93151]
This fixes a bug caused by a mismatch between the macros defined by
<errno.h> when GCC is built and the macros defined by <errno.h> when
users include <system_error>. If the user code is compiled with
_XOPEN_SOURCE defined to 500 or 600, Darwin suppresses the
ENOTRECOVERABLE and EOWNERDEAD macros, which are not defined by SUSv3
(aka POSIX.1-2001).

Since POSIX requires the errno macros to be macros (and not variables or
enumerators) we can just test for them directly using the preprocessor.
That means that <system_error> will match what is actuallydefined when
it's included, not what was defined when GCC was built. With that change
there is no need for the GLIBCXX_CHECK_SYSTEM_ERROR configure checks and
they can be removed.

libstdc++-v3/ChangeLog:

	PR libstdc++/93151
	* acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove.
	* configure.ac: Regenerate.
	* config/os/generic/error_constants.h: Test POSIX errno macros
	directly, instead of corresponding _GLIBCXX_HAVE_EXXX macros.
	* testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc:
	Likewise.
	* testsuite/19_diagnostics/headers/system_error/93151.cc: New
	test.
2020-12-16 13:36:02 +00:00
GCC Administrator
6e9d865119 Daily bump. 2020-12-16 00:16:31 +00:00
Jonathan Wakely
433703843b libstdc++: Remove init_priority attribute for Init object [PR 98108]
This reverts commit cf4ed3b415.

libstdc++-v3/ChangeLog:

    PR libstdc++/98108
    * include/std/iostream (__ioinit): Remove init_priority attribute.
2020-12-15 18:40:28 +00:00
Keith Packard
75aee07269 libstdc++: Support libc with stdio-only I/O in libstdc++
The current libstdc++ basic_file_stdio.cc code assumes a POSIX API
underneath the stdio implementation provided by the host libc. This
means that the host must provide a fairly broad POSIX file API,
including read, write, open, close, lseek and ioctl.

This patch changes basic_file_stdio.cc to only use basic ANSI-C stdio
functions, allowing it to be used with libc implementations like
picolibc which may not have a POSIX operating system underneath.

This is enabled by a new --enable-cstdio=stdio_pure configure option.

Aided-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_CSTDIO): Allow "stdio_pure"
	option and define _GLIBCXX_USE_PURE_STDIO when it is used. Also
	add "stdio_posix" option as an alias for "stdio".
	* config/io/basic_file_stdio.cc [_GLIBCXX_USE_PURE_STDIO]: Only
	use defined stdio entry points for all I/O operations, without
	direct calls to underlying POSIX functions.
	* config.h.in: Regenerate.
	* configure: Regenerate.
2020-12-15 17:39:24 +00:00
Ville Voutilainen
4e096e0ff8 libstdc++: Fix the test for rvalue stream extraction
libstdc++-v3/ChangeLog:

	* testsuite/27_io/rvalue_streams.cc: Run the extraction to a char*
	for C++17 and lower only.
2020-12-15 18:03:43 +02:00
Jonathan Wakely
e831ad4dab libstdc++: Increase timeout for tests in debug mode
These tests FAIL when testing debug mode with a small tool_timeout
value. Give them a longer relative timeout.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
	Add dg-timeout-factor directive.
	* testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc:
	Increase timeout factor from 2.0 to 3.0.
	* testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc:
	Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_debug-mode):
	Define "debug-mode" as an effective-target keyword.
2020-12-15 15:39:58 +00:00
Jonathan Wakely
f072d1021e libstdc++: Do not define constexpr assertions for C++11
There's no point even checking is_constant_evaluated() in C++11 mode,
because the 'if' statement used for the assertion wouldn't be valid in a
C++11 constexpr function anyway.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (__glibcxx_assert_1): Define as empty
	for C++11.
2020-12-15 15:39:58 +00:00
Marius Hillenbrand
7640db5711 libstdc++: Fix required locales of a testcase
The testsuite for libstdc++ aims to skips test cases for which not all
required locales are installed. This patch adds missing directives about
required locales to one test case to avoid false positive test failures
on systems that have a partial set of locales installed.

Verified by test suite runs that this patch changes the test case from
FAIL to UNSUPPORTED when not all required locales are available and that
the test case will run and PASS when the necessary locales have been
added.

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/locale/cons/5.cc: Add missing directives
	for required locales.
2020-12-15 11:45:27 +00:00
Jonathan Wakely
fa452a843d libstdc++: Remove workaround for PR c++/78173
Now that the G++ bug is fixed we no longer need to protect this partial
specialization from complaining about subtracting void pointers.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (incrementable_traits<Tp>):
	Remove workaround for PR c++/78173.
2020-12-15 11:45:27 +00:00
Vladimir Vishnevsky
a929b39aa3 libstdc++: Disabling AC_LIBTOOL_DLOPEN check if building with avr-libc
The AC_LIBTOOL_DLOPEN checks were previously disabled for newlib targets.
The patch applies similar logic to avr-libc based builds.

libstdc++-v3/ChangeLog:

	* configure.ac: Skip AC_LIBTOOL_DLOPEN check if avr-libc is used.
	* configure: Regenerate.
2020-12-15 11:45:26 +00:00
Jonathan Wakely
cf4ed3b415 libstdc++: Use init_priority attribute for Init object [PR 98108]
This causes the global objects that run the <iostream> initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.

libstdc++-v3/ChangeLog:

	PR libstdc++/98108
	* include/std/iostream (__ioinit): Add init_priority attribute.
2020-12-15 11:45:26 +00:00
Gerald Pfeifer
23900be4d3 libstdc++: Update link to Unicode-HOWTO
libstdc++-v3/ChangeLog:

2020-12-15  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/codecvt.xml: Update link to Unicode-HOWTO.
	* doc/html/manual/facets.html: Regenerate.
2020-12-15 09:33:18 +01:00
GCC Administrator
d52945ce54 Daily bump. 2020-12-15 00:16:35 +00:00
François Dumont
4c275e83dd libstdc++: Make tests with Undefined Behavior in C++11 UNSUPPORTED
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/array/debug/back1_neg.cc: Target c++14 because assertion
	is disabled in C++11.
	* testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc: Likewise.
2020-12-14 22:28:38 +01:00
Martin Sebor
fe7f75cf16 Correct/improve maybe_emit_free_warning (PR middle-end/98166, PR c++/57111, PR middle-end/98160).
Resolves:
PR middle-end/98166 - bogus -Wmismatched-dealloc on user-defined allocator and inlining
PR c++/57111 - 57111 - Generalize -Wfree-nonheap-object to delete
PR middle-end/98160 - ICE in default_tree_printer at gcc/tree-diagnostic.c:270

gcc/ChangeLog:

	PR middle-end/98166
	PR c++/57111
	PR middle-end/98160
	* builtins.c (check_access): Call tree_inlined_location
	fndecl_alloc_p): Handle BUILT_IN_ALIGNED_ALLOC and
	BUILT_IN_GOMP_ALLOC.
	call_dealloc_p): Remove unused function.
	(new_delete_mismatch_p): Call valid_new_delete_pair_p and rework.
	(matching_alloc_calls_p): Handle built-in deallocation functions.
	(warn_dealloc_offset): Corrct the handling of user-defined operators
	delete.
	(maybe_emit_free_warning): Avoid assuming expression is a decl.
	Simplify.
	* doc/extend.texi (attribute malloc): Update.
	* tree-ssa-dce.c (valid_new_delete_pair_p): Factor code out into
	valid_new_delete_pair_p in tree.c.
	* tree.c (tree_inlined_location): Define new function.
	(valid_new_delete_pair_p): Define.
	* tree.h (tree_inlined_location): Declare.
	(valid_new_delete_pair_p): Declare.

gcc/c-family/ChangeLog:

	PR middle-end/98166
	PR c++/57111
	PR middle-end/98160
	* c-attribs.c (maybe_add_noinline): New function.
	(handle_malloc_attribute): Call it.  Use ATTR_FLAG_INTERNAL.
	Implicitly add attribute noinline to functions not declared inline
	and warn on those.

libstdc++-v3/ChangeLog:
	* testsuite/ext/vstring/requirements/exception/basic.cc: Suppress
	a false positive warning.
	* testsuite/ext/vstring/requirements/exception/propagation_consistent.cc:
	  Same.

gcc/testsuite/ChangeLog:

	PR middle-end/98166
	PR c++/57111
	PR middle-end/98160
	* g++.dg/warn/Wmismatched-dealloc-2.C: Adjust test of expected warning.
	* g++.dg/warn/Wmismatched-new-delete.C: Same.
	* gcc.dg/Wmismatched-dealloc.c: Same.
	* c-c++-common/Wfree-nonheap-object-2.c: New test.
	* c-c++-common/Wfree-nonheap-object-3.c: New test.
	* c-c++-common/Wfree-nonheap-object.c: New test.
	* c-c++-common/Wmismatched-dealloc.c: New test.
	* g++.dg/warn/Wfree-nonheap-object-3.C: New test.
	* g++.dg/warn/Wfree-nonheap-object-4.C: New test.
	* g++.dg/warn/Wmismatched-dealloc-2.C: New test.
	* g++.dg/warn/Wmismatched-new-delete-2.C: New test.
	* g++.dg/warn/Wmismatched-new-delete.C: New test.
	* gcc.dg/Wmismatched-dealloc-2.c: New test.
	* gcc.dg/Wmismatched-dealloc-3.c: New test.
	* gcc.dg/Wmismatched-dealloc.c: New test.
2020-12-14 13:30:00 -07:00
François Dumont
8e56e4d956 libstdc++: Fix several _GLIBCXX_DEBUG tests
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/array/debug/back2_neg.cc: target c++14 because assertion
	for constexpr is disabled in C++11.
	* testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc: Likewise.
	* testsuite/23_containers/vector/debug/multithreaded_swap.cc: Include <memory>
	for shared_ptr.
2020-12-14 07:46:25 +01:00
GCC Administrator
9855e8a90d Daily bump. 2020-12-13 00:16:19 +00:00
François Dumont
815eb852a2 libstdc++: Fix _GLIBCXX_DEBUG mode constexpr compatibility
The __glibcxx_check_can_[increment|decrement]_range macros are using the
_GLIBCXX_DEBUG_VERIFY_COND_AT macro which is not constexpr compliant and will produce nasty
diagnostics rather than the std::__failed_assertion dedicated to constexpr. Replace it with
correct _GLIBCXX_DEBUG_VERIFY_AT_F.

libstdc++-v3/ChangeLog:

	* include/debug/macros.h (__glibcxx_check_can_increment_range): Replace
	_GLIBCXX_DEBUG_VERIFY_COND_AT usage with _GLIBCXX_DEBUG_VERIFY_AT_F.
	(__glibcxx_check_can_decrement_range): Likewise.
	* testsuite/25_algorithms/copy_backward/constexpr.cc (test03): New.
	* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: New test.
	* testsuite/25_algorithms/copy_backward/debug/constexpr_neg.cc: New test.
	* testsuite/25_algorithms/equal/constexpr_neg.cc: New test.
	* testsuite/25_algorithms/equal/debug/constexpr_neg.cc: New test.
2020-12-12 18:07:45 +01:00
GCC Administrator
35af87784e Daily bump. 2020-12-11 18:22:52 +00:00
Jonathan Wakely
2ea62857a3 libstdc++: Remove redundant branches in countl_one and countr_one [PR 98226]
There's no need to explicitly check for the maximum value, because the
function we call handles it correctly anyway.

libstdc++-v3/ChangeLog:

	PR libstdc++/98226
	* include/std/bit (__countl_one, __countr_one): Remove redundant
	branches.
2020-12-10 21:57:42 +00:00
GCC Administrator
ca2bd94949 Daily bump. 2020-12-10 00:16:47 +00:00
Jonathan Wakely
0aa1786d34 libstdc++: Fix build failure for target with no way to sleep
In previous releases the std::this_thread::sleep_for function was only
declared if the target supports multiple threads. I changed that
recently in r11-2649-g5bbb1f3000c57fd4d95969b30fa0e35be6d54ffb so that
sleep_for could be used single-threaded. But that means that targets
using --disable-threads are now required to provide some way to sleep.
This breaks the build for (at least) AVR when trying to build a hosted
library.

This patch adds a new autoconf macro that is defined when no way to
sleep is available, and uses that to suppress the sleeping functions in
std::this_thread.

The #error in src/c++11/thread.cc is retained for the case where there
is no sleep function available but multiple threads are supported. This
is consistent with previous releases, but that #error could probably be
removed without any consequences.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Define NO_SLEEP
	if none of nanosleep, sleep and Sleep is available.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/std/thread [_GLIBCXX_NO_SLEEP] (__sleep_for): Do
	not declare.
	[_GLIBCXX_NO_SLEEP] (sleep_for, sleep_until): Do not
	define.
	* src/c++11/thread.cc [_GLIBCXX_NO_SLEEP] (__sleep_for): Do
	not define.
2020-12-09 16:56:54 +00:00
GCC Administrator
f6e8e2797e Daily bump. 2020-12-09 00:16:50 +00:00
Jason Merrill
4ed1dc1275 c++: Fix defaulted <=> fallback to < and == [PR96299]
I thought I had implemented P1186R3, but apparently I didn't read it closely
enough to understand the point of the paper, namely that for a defaulted
operator<=>, if a member type doesn't have a viable operator<=>, we will use
its operator< and operator== if the defaulted operator has an specific
comparison category as its return type; the compiler can't guess if it
should be strong_ordering or something else, but the user can make that
choice explicit.

The libstdc++ test change was necessary because of the change in
genericize_spaceship from op0 > op1 to op1 < op0; this should be equivalent,
but isn't because of PR88173.

gcc/cp/ChangeLog:

	PR c++/96299
	* cp-tree.h (build_new_op): Add overload that omits some parms.
	(genericize_spaceship): Add location_t parm.
	* constexpr.c (cxx_eval_binary_expression): Pass it.
	* cp-gimplify.c (genericize_spaceship): Pass it.
	* method.c (genericize_spaceship): Handle class-type arguments.
	(build_comparison_op): Fall back to op</== when appropriate.

gcc/testsuite/ChangeLog:

	PR c++/96299
	* g++.dg/cpp2a/spaceship-synth-neg2.C: Move error.
	* g++.dg/cpp2a/spaceship-p1186.C: New test.

libstdc++-v3/ChangeLog:

	PR c++/96299
	* testsuite/18_support/comparisons/algorithms/partial_order.cc:
	One more line needs to use VERIFY instead of static_assert.
2020-12-08 15:12:25 -05:00
Jonathan Wakely
edbbf7363c libstdc++: Adjust whitespace in documentation
libstdc++-v3/ChangeLog:

	* doc/xml/manual/appendix_contributing.xml: Use consistent
	indentation.
	* doc/html/manual/source_code_style.html: Regenerate.
2020-12-08 13:36:45 +00:00
GCC Administrator
6e1edf48eb Daily bump. 2020-12-06 00:16:44 +00:00
Iain Sandoe
1352bc88a0 Darwin : Update libtool and dependencies for Darwin20 [PR97865]
The change in major version (and the increment from Darwin19 to 20)
caused libtool tests to fail which resulted in incorrect build settings
for shared libraries.

We take this opportunity to sort out the shared undefined symbols state
rather than propagating the current unsound behaviour into a new rev.

This change means that we default to the case that missing symbols are
considered an error, and if one wants to allow this intentionally, the
confiuration for that case should be set appropriately.

Three existing cases need undefined dynamic lookup:
 libitm, where there is already a configuration mechanism to add the
         flags.
 libcc1, where we add simple configuration to add the flags for Darwin.
 libsanitizer, where we can add to the existing extra flags.

libcc1/ChangeLog:

	PR target/97865
	* Makefile.am: Add dynamic_lookup to LD flags for Darwin.
	* configure.ac: Test for Darwin host and set a flag.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

libitm/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to XLDFLAGS for Darwin.
	* configure: Regenerate.

libsanitizer/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to EXTRA_CXXFLAGS for
	Darwin.
	* configure: Regenerate.

ChangeLog:

	PR target/97865
	* libtool.m4: Update handling of Darwin platform link flags
	for Darwin20.

gcc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libatomic/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libbacktrace/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libffi/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgfortran/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgomp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libhsail-rt/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libobjc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libphobos/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libquadmath/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libssp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libvtv/ChangeLog:

	PR target/97865
	* configure: Regenerate.

zlib/ChangeLog:

	PR target/97865
	* configure: Regenerate.
2020-12-05 08:43:20 +00:00
GCC Administrator
c5fd8a9157 Daily bump. 2020-12-05 00:16:39 +00:00
Jakub Jelinek
9715663f7d c++: Change __builtin_source_location to use __PRETTY_FUNCTION__ instead of __FUNCTION__ [PR80780]
On Tue, Dec 01, 2020 at 01:03:52PM +0000, Jonathan Wakely via Gcc-patches wrote:
> I mentioned in PR 80780 that a __builtin__PRETTY_FUNCTION would have
> been nice, because __FUNCTION__ isn't very useful for C++, because of
> overloading and namespace/class scopes. There are an unlimited number
> of functions that have __FUNCTION__ == "s", e.g. "ns::s(int)" and
> "ns::s()" and "another_scope::s::s<T...>(T...)" etc.
>
> Since __builtin_source_location() can do whatever it wants (without
> needing to add __builtin__PRETTY_FUNCTION) it might be nice to use the
> __PRETTY_FUNCTION__ string. JeanHeyd's tests would still need changes,
> because the name would be "s::s(void*)" not "s::s" but that still
> seems better for users.

When I've added template tests for the previous patch, I have noticed that
the current __builtin_source_location behavior is not really __FUNCTION__,
just close, because e.g. in function template __FUNCTION__ is still
"bar" but __builtin_source_location gave "bar<0>".

Anyway, this patch implements above request to follow __PRETTY_FUNCTION__
(on top of the earlier posted patch).

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/80780
	* cp-gimplify.c (fold_builtin_source_location): Use 2 instead of 0
	as last argument to cxx_printable_name.

	* g++.dg/cpp2a/srcloc1.C (quux): Use __PRETTY_FUNCTION__ instead of
	function.
	* g++.dg/cpp2a/srcloc2.C (quux): Likewise.
	* g++.dg/cpp2a/srcloc15.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.
	* g++.dg/cpp2a/srcloc17.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.

	* testsuite/18_support/source_location/1.cc (main): Adjust for
	__builtin_source_location using __PRETTY_FUNCTION__-like names instead
	__FUNCTION__-like.
	* testsuite/18_support/source_location/consteval.cc (main): Likewise.
2020-12-04 08:08:39 +01:00
GCC Administrator
b8dd0ef74d Daily bump. 2020-12-04 00:16:36 +00:00
Martin Sebor
dce6c58db8 Add support for detecting mismatched allocation/deallocation calls.
PR c++/90629 - Support for -Wmismatched-new-delete
PR middle-end/94527 - Add an __attribute__ that marks a function as freeing an object

gcc/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* builtins.c (access_ref::access_ref): Initialize new member.
	(compute_objsize): Use access_ref::deref.  Handle simple pointer
	assignment.
	(expand_builtin): Remove handling of the free built-in.
	(call_dealloc_argno): Same.
	(find_assignment_location): New function.
	(fndecl_alloc_p): Same.
	(gimple_call_alloc_p): Same.
	(call_dealloc_p): Same.
	(matching_alloc_calls_p): Same.
	(warn_dealloc_offset): Same.
	(maybe_emit_free_warning): Same.
	* builtins.h (struct access_ref): Declare new member.
	(maybe_emit_free_warning): Make extern.  Make use of access_ref.
	Handle -Wmismatched-new-delete.
	* calls.c (initialize_argument_information): Call
	maybe_emit_free_warning.
	* doc/extend.texi (attribute malloc): Update.
	* doc/invoke.texi (-Wfree-nonheap-object): Expand documentation.
	(-Wmismatched-new-delete): Document new option.
	(-Wmismatched-dealloc): Document new option.

gcc/c-family/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* c-attribs.c (handle_dealloc_attribute): New function.
	(handle_malloc_attribute): Handle argument forms of attribute.
	* c.opt (-Wmismatched-dealloc): New option.
	(-Wmismatched-new-delete): New option.

gcc/testsuite/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* g++.dg/asan/asan_test.cc: Fix a bug.
	* g++.dg/warn/delete-array-1.C: Add expected warning.
	* g++.old-deja/g++.other/delete2.C: Add expected warning.
	* g++.dg/warn/Wfree-nonheap-object-2.C: New test.
	* g++.dg/warn/Wfree-nonheap-object.C: New test.
	* g++.dg/warn/Wmismatched-new-delete.C: New test.
	* g++.dg/warn/Wmismatched-dealloc-2.C: New test.
	* g++.dg/warn/Wmismatched-dealloc.C: New test.
	* gcc.dg/Wmismatched-dealloc.c: New test.
	* gcc.dg/analyzer/malloc-1.c: Prune out expected warning.
	* gcc.dg/attr-malloc.c: New test.
	* gcc.dg/free-1.c: Adjust text of expected warning.
	* gcc.dg/free-2.c: Same.
	* gcc.dg/torture/pr71816.c: Prune out expected warning.
	* gcc.dg/tree-ssa/pr19831-2.c: Add an expected warning.
	* gcc.dg/Wfree-nonheap-object-2.c: New test.
	* gcc.dg/Wfree-nonheap-object-3.c: New test.
	* gcc.dg/Wfree-nonheap-object.c: New test.

libstdc++-v3/ChangeLog:

	* testsuite/ext/vstring/modifiers/clear/56166.cc: Suppress a false
	positive warning.
2020-12-03 15:43:32 -07:00
Jonathan Wakely
656131e06a libstdc++: Fix typos in #error strings
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Remove stray
	word from copy&paste.
	* testsuite/26_numerics/bit/bit.cast/version.cc: Likewise.
2020-12-03 19:31:19 +00:00
Jonathan Wakely
44ac1ea0e2 libstdc++: Update C++20 library implementation status
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml: Update C++20 status.
	* doc/html/*: Regenerate.
2020-12-03 19:17:13 +00:00
JeanHeyd Meneide
57d76ee9cf libtdc++: Define std::source_location for C++20
This doesn't define a new _GLIBCXX_HAVE_BUILTIN_SOURCE_LOCATION macro.
because using __has_builtin(__builtin_source_location) is sufficient.
Currently only GCC supports it, but if/when Clang and Intel add it the
__has_builtin check should for them too.

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

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add <source_location>.
	* include/Makefile.am: Add <source_location>.
	* include/Makefile.in: Regenerate.
	* include/std/version (__cpp_lib_source_location): Define.
	* include/std/source_location: New file.
	* testsuite/18_support/source_location/1.cc: New test.
	* testsuite/18_support/source_location/consteval.cc: New test.
	* testsuite/18_support/source_location/srcloc.h: New test.
	* testsuite/18_support/source_location/version.cc: New test.
2020-12-03 19:17:13 +00:00
Jonathan Wakely
9e433b3461 libstdc++: Add std::bit_cast for C++20 [PR 93121]
Thanks to Jakub's addition of the built-in, we can add this to the
library now. The compiler tests for the built-in are quite extensive,
including verifying the constraints, so this only adds minimal tests to
the library testsuite.

This doesn't add a new _GLIBCXX_HAVE_BUILTIN_BIT_CAST because using
__has_builtin(__builtin_bit_cast) works for GCC and versions of Clang
that provide the built-in.

libstdc++-v3/ChangeLog:

	PR libstdc++/93121
	* include/std/bit (__cpp_lib_bit_cast, bit_cast): Define.
	* include/std/version (__cpp_lib_bit_cast): Define.
	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: New test.
	* testsuite/26_numerics/bit/bit.cast/version.cc: New test.
2020-12-03 19:17:13 +00:00
Jonathan Wakely
3843fa2d75 libstdc++: Update powerpc-linux baselines for GCC 10.1
This should have been done before the GCC 10.1 release.

libstdc++-v3/ChangeLog:

	* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt:
	Update.
	* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
	Update.
2020-12-03 17:18:28 +00:00
Jonathan Wakely
91cfacc4b5 libstdc++: Disable std::array assertions for C++11 constexpr
The recent changes to add assertions to std::array broke the functions
that need to be constexpr in C++11, because of the restrictive rules for
constexpr functions in C++11.

This simply disables the assertions for C++11 mode, so the functions can
be constexpr again.

libstdc++-v3/ChangeLog:

	* include/std/array (array::operator[](size_t) const, array::front() const)
	(array::back() const) [__cplusplus == 201103]: Disable
	assertions.
	* testsuite/23_containers/array/element_access/constexpr_element_access.cc:
	Check for correct values.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/23_containers/array/debug/constexpr_c++11.cc: New test.
2020-12-03 17:08:01 +00:00
GCC Administrator
11860cf440 Daily bump. 2020-12-03 00:16:47 +00:00
Jonathan Wakely
dc2b372ed1 libstdc++: Fix std::any pretty printer [PR 68735]
This fixes errors seen on powerpc64 (big endian only) due to the
printers for std::any and std::experimental::any being unable to find
the manager function.

libstdc++-v3/ChangeLog:

	PR libstdc++/65480
	PR libstdc++/68735
	* python/libstdcxx/v6/printers.py (function_pointer_to_name):
	New helper function to get the name of a function from its
	address.
	(StdExpAnyPrinter.__init__): Use it.
2020-12-02 21:39:08 +00:00
Jonathan Wakely
dd053eea0b libstdc++: Use libatomic for tests on all 32-bit powerpc targets
In addition to the existing powerpc targets, powerpc64 needs libatomic
for 64-bit atomics when testing the 32-bit multilib with -m32. Adjust
the existing target checks to match all 32-bit powerpc targets, but not
64-bit ones.

libstdc++-v3/ChangeLog:

	* testsuite/lib/dg-options.exp (add_options_for_libatomic):
	Replace powerpc-ibm-aix* and powerpc*-*-darwin* with check for
	powerpc && ilp32.
2020-12-02 16:37:56 +00:00
Jonathan Wakely
8b2c3b5af3 libstdc++: Use longer timeout for istream::gcount() overflow tests
On targets with 32-bit poitners these tests do extra work, so give them
longer to run.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_istream/ignore/char/94749.cc: Add
	dg-timeout-factor for ilp32 targets.
	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc:
	Likewise.
2020-12-02 12:34:20 +00:00
Jonathan Wakely
74270a546c libstdc++: Fix null pointer dereferences in __gnu_cxx::rope
This fixes UBsan errors like:

/usr/include/c++/10/ext/ropeimpl.h:593:9: runtime error: member access within null pointer of type 'struct _RopeRep'
/usr/include/c++/10/ext/ropeimpl.h:593:9: runtime error: member call on null pointer of type 'struct _Rope_rep_base'
/usr/include/c++/10/ext/rope:556:17: runtime error: reference binding to null pointer of type 'struct allocator_type'
/usr/include/c++/10/ext/ropeimpl.h:593:9: runtime error: reference binding to null pointer of type 'struct allocator_type'
/usr/include/c++/10/ext/rope:1700:30: runtime error: member call on null pointer of type 'struct new_allocator'
/usr/include/c++/10/ext/new_allocator.h:105:29: runtime error: member call on null pointer of type 'struct new_allocator'
/usr/include/c++/10/ext/rope:1702:26: runtime error: reference binding to null pointer of type 'const struct allocator'
/usr/include/c++/10/bits/allocator.h:148:34: runtime error: reference binding to null pointer of type 'const struct new_allocator'
/usr/include/c++/10/ext/rope:1664:39: runtime error: reference binding to null pointer of type 'const struct allocator'
/usr/include/c++/10/ext/rope:1665:9: runtime error: reference binding to null pointer of type 'const struct allocator_type'
/usr/include/c++/10/ext/rope:725:36: runtime error: reference binding to null pointer of type 'const struct allocator_type'
/usr/include/c++/10/ext/rope:614:64: runtime error: reference binding to null pointer of type 'const struct allocator_type'

The problem is calling r->_M_get_allocator() when r is null.

libstdc++-v3/ChangeLog:

	* include/ext/rope (rope::_S_concat_char_iter)
	(rope::_S_destr_concat_char_iter): Add allocator parameter.
	(rope::push_back, rope::append, rope::insert, operator+):
	Pass allocator.
	* include/ext/ropeimpl.h (rope::_S_concat_char_iter)
	(rope::_S_destr_concat_char_iter): Add allocator parameter
	and use it.
	(_Rope_char_ref_proxy::operator=(_CharT)): Pass allocator.
2020-12-02 12:29:00 +00:00
Jonathan Wakely
d38fbb5a86 libstdc++: Fix indentation in rope
libstdc++-v3/ChangeLog:

	* include/ext/rope: Fix indentation of access specifiers.
2020-12-02 12:28:22 +00:00
Jonathan Wakely
670f5095e4 libstdc++: Make preprocessor checks for __cpp_lib_atomic_wait consistent
This changes some #ifdef checks to use #if instead.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h: Use #if instead of #ifdef.
	* include/bits/semaphore_base.h: Likewise.
	* include/std/version: Remove trailing whitespace.
2020-12-02 00:39:22 +00:00
Jonathan Wakely
a70384f94c libstdc++: Fix filesystem::path pretty printer test failure
On some systems libstdc++-prettyprinters/cxx17.cc FAILs with this error:

skipping: Python Exception <type 'exceptions.AttributeError'> 'gdb.Type' object has no attribute 'name': ^M
got: $27 = filesystem::path "/dir/."^M
FAIL: libstdc++-prettyprinters/cxx17.cc print path2

The gdb.Type.name attribute isn't present in GDB 7.6, so we get an
exception from StdPathPrinter._iterator.__next__ trying to use it.
The StdPathPrinter._iterator is already passed the type's name in its
constructor, so we can just store that and use it instead of
gdb.Type.name.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdExpPathPrinter): Store the
	name of the type and pass it to the iterator.
	(StdPathPrinter): Likewise.
	* testsuite/libstdc++-prettyprinters/filesystem-ts.cc: New test.
2020-12-02 00:39:21 +00:00
GCC Administrator
e0f5e79267 Daily bump. 2020-12-02 00:16:41 +00:00
Thomas Rodgers
6591e42269 Add feature test macro for atomic<T>::wait
Adds __cpp_lib_atomic_wait feature test macro which was overlooked in
the initial commit of this feature. Replaces uses of
_GLIBCXX_HAVE_ATOMIC_WAIT.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h: Replace usage of
	_GLIBCXX_HAVE_ATOMIC_WAIT with __cpp_lib_atomic_wait.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/atomic_wait.h: Define __cpp_lib_atomic_wait
	feature test macro.
	* include/bits/semaphore_base.h: Replace usage of
	_GLIBCXX_HAVE_ATOMIC_WAIT with __cpp_lib_atomic_wait.
	* include/std/atomic: Likewise.
	* include/std/latch: Likewise.
	* include/std/semaphore: Likewise.
	* include/std/version: Define __cpp_lib_atomic wait
	feature test macro and replace usage of
	_GLIBCXX_HAVE_ATOMIC_WAIT.
	* testsuite/29_atomics/atomic/wait_notify/1.cc: New test.
	* testsuite/29_atomics/atomic/wait_notify/2.cc: Likewise.
2020-12-01 15:43:17 -08:00
Michael Weghorn
39836f8324 libstdc++: Pretty printers for _Bit_reference and _Bit_iterator
'std::_Bit_iterator' and 'std::_Bit_const_iterator' are the iterators
used by 'std::vector<bool>'.
'std::_Bit_reference' is e.g. used in range-based for loops over
'std::vector<bool>'  like

    std::vector<bool> vb {true, false, false};
    for (auto b : vb) {
        // b is of type std::_Bit_reference here
        // ...
    }

Like iterators of vectors for other types, the actual value is printed.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdBitIteratorPrinter)
	(StdBitReferencePrinter): Add pretty-printers for
	_Bit_reference, _Bit_iterator and _Bit_const_iterator.
	* testsuite/libstdc++-prettyprinters/simple.cc: Test
	std::_Bit_reference, std::_Bit_iterator and
	std::_Bit_const_iterator.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
2020-12-01 21:35:32 +00:00
Jonathan Wakely
6aa1227400 libstdc++: Simplify detection of built-in functions
This fixes a regression affecting the Intel compiler. Because that
compiler defines __GNUC__ to match whatever version of GCC it finds on
the host system, it might claim to be a brand new GCC despite not
actually supporting all the built-ins that the latest GCC supports. This
means the config checks for __GNUC__ don't work. Most recently this
broke when r11-3569-g73ae6eb572515ad627b575a7fbdfdd47a4368e1c switched
us from using __is_same_as to __is_same when __GNUC__ >= 11.

Because __has_builtin is supported by all of GCC, Clang, and Intel we can
use that to reliably detect whether a given built-in is supported,
instead of hardcoding anything based on __GNUC__. The big caveat is
that for versions of Clang <= 9.0.0 and for (as far as I can tell) all
released versions of Intel icc, __has_builtin only evaluates to true for
built-ins with a name starting "__builtin_". For __is_aggregate,
__is_same, and __has_unique_object_representations it's necessary to use
__is_identifier to check if it's a valid identifeir token instead.

The solution used in this patch is to define _GLIBCXX_HAS_BUILTIN and
use that instead of using __has_builtin directly. For compilers that
define __is_identifier as well as __has_builtin we use both, so that if
__has_builtin evaluates to false we try again using !__is_identifier.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_HAS_BUILTIN): Define macro to
	work around different implementations of __has_builtin.
	(_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP)
	(_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE)
	(_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED)
	(_GLIBCXX_HAVE_BUILTIN_IS_SAME, _GLIBCXX_HAVE_BUILTIN_LAUNDER):
	Define using _GLIBCXX_HAS_BUILTIN.
2020-12-01 14:14:18 +00:00
Jonathan Wakely
0fb378761f libstdc++: Use longer timeout for slow running tests
libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_istream/get/char/lwg3464.cc: Add
	dg-timeout-factor directive.
	* testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc:
	Likewise.
2020-12-01 10:51:25 +00:00
Jonathan Wakely
58f71a34c6 libstdc++: Link test with libatomic if needed [PR 98003]
libstdc++-v3/ChangeLog:

	PR libstdc++/98003
	* testsuite/27_io/basic_syncbuf/sync_ops/1.cc: Add options for
	libatomic.
2020-12-01 10:37:38 +00:00
GCC Administrator
94358e4770 Daily bump. 2020-12-01 00:16:38 +00:00
Jonathan Wakely
82ac923da6 libstdc++: Add new C++20 headers to Doxygen settings
This doesn't actually have any effect unless you also change the
predefined value of __cplusplus, as it's currently 201703L. But if
somebody does want to do that, the new headers will get processed now.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add <latch> and <semaphore>.
2020-11-30 15:02:03 +00:00
Jonathan Wakely
637800c7bb libstdc++: Reduce default test timeout to 360 seconds
The current default of 10 minutes is much longer than most tests need on
common hardware. The slow tests all now have a dg-timeout-factor
directive that gives them more time to run relative to the default. The
default can also be overridden in ~/.dejagnurc or DEJAGNU=site.exp, so
it seems unnecessary to have such a large default.

This reduces the default from 10 minutes to 6 minutes, which still seems
more than enough.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (libstdc++_init): Reduce
	default tool_timeout to 360.
2020-11-30 14:39:54 +00:00
Jonathan Wakely
b6a8e3479e libstdc++: Set dg-timeout-factor for more slow tests
As in r11-5449, this adds a muliplier to the timeout for slow tests.
This covers the majority of the <regex> and PSTL tests.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/pstl/*: Add
	dg-timeout-factor.
	* testsuite/25_algorithms/pstl/*: Likewise.
	* testsuite/26_numerics/pstl/*: Likewise.
	* testsuite/28_regex/*: Likewise.
2020-11-30 14:39:54 +00:00
GCC Administrator
a9625c50dd Daily bump. 2020-11-30 00:16:27 +00:00
John David Anglin
4e4ba6478a Fix hppa64-hpux11 build to remove source paths from embedded path.
This change adds the +nodefaultrpath ld option to remove all library
paths that were specified with the -L option from the embedded path.

2020-11-29  John David Anglin  <danglin@gcc.gnu.org>

ChangeLog:
	* libtool.m4 (archive_cmds): Add +nodefaultrpath ld option on
	hppa64-*-hpux11*.

libatomic/ChangeLog:
	* configure: Regenerate.

libbacktrace/ChangeLog:
	* configure: Regenerate.

libcc1/ChangeLog:
	* configure: Regenerate.

libffi/ChangeLog:
	* configure: Regenerate.

libgfortran/ChangeLog:
	* configure: Regenerate.

libgomp/ChangeLog:
	* configure: Regenerate.

libhsail-rt/ChangeLog:
	* configure: Regenerate.

libitm/ChangeLog:
	* configure: Regenerate.

libobjc/ChangeLog:
	* configure: Regenerate.

liboffloadmic/ChangeLog:
	* configure: Regenerate.
	* plugin/configure: Regenerate.

libquadmath/ChangeLog:
	* configure: Regenerate.

libsanitizer/ChangeLog:
	* configure: Regenerate.

libssp/ChangeLog:
	* configure: Regenerate.

libstdc++-v3/ChangeLog:
	* configure: Regenerate.

libvtv/ChangeLog:
	* configure: Regenerate.

lto-plugin/ChangeLog:
	* configure: Regenerate.

zlib/ChangeLog:
	* configure: Regenerate.
2020-11-29 20:11:38 +00:00
GCC Administrator
e87559d202 Daily bump. 2020-11-28 00:16:38 +00:00
Jonathan Wakely
e8f83fa4fc libstdc++: Refactor dejagnu effective-target checks
This introduces two new procs to replace boilerplate in the
effective-target checks.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (v3_try_preprocess): Define
	new proc to preprocess a chunk of code.
	(v3_check_preprocessor_condition): Define new proc to test
	a preprocessor condition depending on GCC or libstdc++ macros.
	(check_v3_target_debug_mode, check_v3_target_normal_mode):
	Use v3_try_preprocess.
	(check_v3_target_normal_namespace)
	(check_v3_target_parallel_mode, check_v3_target_cstdint)
	(check_v3_target_cmath, check_v3_target_atomic_builtins)
	(check_v3_target_gthreads, check_v3_target_gthreads_timed)
	(check_v3_target_sleep, check_v3_target_sched_yield)
	(check_v3_target_string_conversions, check_v3_target_swprintf)
	(check_v3_target_binary_io, check_v3_target_nprocs): Use
	v3_check_preprocessor_condition.
	(check_effective_target_cxx11): Likewise.
	(check_effective_target_random_device): Likewise.
	(check_effective_target_tbb-backend): Likewise.
	(check_effective_target_futex): Likewise.
	(check_v3_target_little_endian) Call check_effective_target_le.
	(check_effective_target_atomic-builtins): New proc to define
	new effective-target keyword.
	(check_effective_target_gthreads-timed): Likewise.
2020-11-27 15:50:49 +00:00
Jonathan Wakely
4a7c799908 libstdc++: Fix -Wrange-loop-construct warnings in filesystem tests
Many tests do `for (const path& p : test_paths)` where test_paths is an
array of strings. To avoid -Wrange-loop-construct warnings the loop
variable should be an object, not a reference bound to a temporary.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/operations/absolute.cc: Avoid
	-Wrange-loop-construct warning.
	* testsuite/27_io/filesystem/path/append/source.cc: Likewise.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/parent_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/relative_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
	* testsuite/27_io/filesystem/path/modifiers/remove_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/nonmember/append.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/cmp.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/cmp_c++20.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/nonmember/hash_value.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_parent_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_relative_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_name.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/is_relative.cc: Likewise.
	* testsuite/experimental/filesystem/operations/absolute.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/assign/copy.cc: Likewise.
	* testsuite/experimental/filesystem/path/compare/path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/construct/copy.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/extension.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/parent_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/relative_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/root_directory.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/root_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/itr/traversal.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/modifiers/remove_filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/modifiers/replace_extension.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/modifiers/replace_filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/nonmember/hash_value.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_extension.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_parent_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_relative_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_root_directory.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_root_name.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_root_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_stem.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/is_relative.cc:
	Likewise.
2020-11-27 13:34:22 +00:00
Jonathan Wakely
0d7d69ca4a libstdc++: Partially revert r11-5314
The changes in r11-5314 are broken, because it means we don't use
__gthread_once for the first few initializations, but after the program
becomes multi-threaded we will repeat the initialization, using
__gthread_once once this time. This leads to memory errors.

The use of __is_single_threaded() in locale:🆔:_M_id() is OK, because
the side effects are the same either way.

libstdc++-v3/ChangeLog:

	* src/c++98/locale.cc (locale::facet::_S_get_c_locale()):
	Revert change to use __is_single_threaded.
	* src/c++98/locale_init.cc (locale::_S_initialize()):
	Likewise.
2020-11-27 12:25:02 +00:00
GCC Administrator
d48df6f24b Daily bump. 2020-11-27 00:16:31 +00:00
Jonathan Wakely
61c71a6245 libstdc++: Define (and use) _GLIBCXX_HAVE_ATOMIC_WAIT
In order to simplify the preprocessor checks for whether __atomic_wait
is available, this commit does:

-#if defined _GLIBCXX_HAS_GTHREADS || _GLIBCXX_HAVE_LINUX_FUTEX
+#ifdef _GLIBCXX_HAVE_ATOMIC_WAIT

The original was wrong anyway, as it should have used 'defined' to check
_GLIBCXX_HAVE_LINUX_FUTEX (for consistency with how that's used
elsewhere).

The new macro is defined in <bits/atomic_wait.h> when the file is
defines __atomic_wait and related facilities. All other code that
depends on those features can just check the one macro.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h (_GLIBCXX_HAVE_ATOMIC_WAIT):
	Define.
	* include/bits/atomic_base.h: Check _GLIBCXX_HAVE_ATOMIC_WAIT.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/semaphore_base.h: Likewise.
	* include/std/atomic: Likewise.
	* include/std/latch: Likewise.
	* include/std/semaphore: Likewise.
2020-11-26 23:53:09 +00:00
Jonathan Wakely
7198827486 libstdc++: Only define std::latch if atomic waiting is available
libstdc++-v3/ChangeLog:

	* include/std/latch: Depend on _GLIBCXX_HAS_GTHREADS and
	_GLIBCXX_HAVE_LINUX_FUTEX.
	* include/std/version (__cpp_lib_latch): Define conditionally.
2020-11-26 22:36:44 +00:00
Jonathan Wakely
1a00786414 libstc++: Fix typo in new check_effective_target_gthreads proc
Also fix copy&pasted comments referring to the wrong things.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (check_effective_target_gthreads):
	Call check_v3_target_gthreads not check_v3_target_gthreads_timed.
2020-11-26 21:43:18 +00:00
Jonathan Wakely
218cedd5a3 libstdc++: Set dg-timeout-factor for some slow tests
These tests are very, very slow to compile. If the testsuite is run with
a low tool_timeout value they are likely to fail. By adding a
multiplication factor to those tests, it's still possible to use a low
timeout without spurious failures.

libstdc++-v3/ChangeLog:

	* testsuite/28_regex/algorithms/regex_match/basic/string_range_01_03.cc:
	Add dg-timeout-factor directive.
	* testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/char/backref.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/63199.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/cjk_match.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_search/61720.cc: Likewise.
	* testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc:
	Likewise.
	* testsuite/28_regex/basic_regex/ctors/deduction.cc: Likewise.
2020-11-26 16:15:53 +00:00
Jonathan Wakely
39e837cd75 libstdc++: Allow dejagnu tool_timeout to be overridden
This allows the default timeout for libstdc++ tests to be set by the
user, either in ~/.dejagnurc or a site.exp file that $DEJAGNU names.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (libstdc++_init): Only set
	tool_timeout if it hasn't been set by the user already.
2020-11-26 16:15:53 +00:00
Jonathan Wakely
10522ed108 libstdc++: Fix some more deadlocks in tests [PR 97936]
The missed notifications fixed in r11-5383 also happen in some other
tests which have similar code.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Fix missed
	notifications by making the new thread wait until the parent
	thread is waiting on the condition variable.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
2020-11-26 16:15:52 +00:00
Jonathan Wakely
10ee46adf4 libstdc++: Add "futex" and "gthreads" effective-target keywords
This adds a new "futex" effective-target keyword that can be used to
selectively enable/disable tests based on _GLIBCXX_HAVE_LINUX_FUTEX,
instead of checking for that macro in the code.

It also adds "gthreads" as another one, to make the result of the
dg-require-gthreads directive usable in target selectors.

With these new keywords two tests that are currently only run for linux
can also be run for targets using gthr-single.h (e.g. AIX single-thread
multilib, and targets without a gthreads implementation).

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Use new effective-target
	keywords to select supported targets more effectively.
	* testsuite/30_threads/call_once/66146.cc: Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_futex):
	Define new proc.
	(check_effective_target_gthreads): Define new proc to replace
	dg-require-gthreads.
2020-11-26 16:15:52 +00:00
Rainer Orth
55ebb0d6fb ada: c++: Get rid of libposix4, librt on Solaris
I recently noticed that neither libposix4 nor librt are needed on
Solaris 11 any longer:

* libposix4 was renamed to librt in Solaris 7 back in 1998.

* librt was folded into libc in the OpenSolaris timeframe, leaving librt
  only as a filter on libc.  Thus, it's no longer needed on either
  Solaris 11 or Illumos.

The following patch removes both uses.  At the same time, Ada's use of
libthread has gone: it was folded into libc in Solaris 10 already.
TIME_LIBRARY and friends in g++ are likewise removed: Solaris was the
only user.

Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.


2020-11-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/cp:
	* g++spec.c (TIMELIB, TIME_LIBRARY): Remove.
	(lang_specific_driver): Remove TIME_LIBRARY handling.

	gcc:
	* config/sol2.h (TIME_LIBRARY): Remove.

	libstdc++-v3:
	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Remove libposix4
	references.
	<solaris*>: Don't use -lrt any longer.
	* configure: Regenerate.

	* doc/xml/manual/configure.xml (--enable-libstdcxx-time=OPTION):
	Remove libposix4 reference.

	gcc/ada:
	* Makefile.rtl <sparc*-sun-solaris*> (THREADSLIB): Remove.
	(MISCLIB): Remove -lposix4.
	<*86-*-solaris2*>: Likewise.
	* libgnarl/s-osinte__solaris.ads (System.OS_Interface): Remove
	-lposix4 -lthread.
2020-11-26 13:01:30 +01:00
Jonathan Wakely
2762cb1df6 libstdc++: Fix undefined FILE* operations in test
We only need to check that the constructor doesn't clear errno, so
there's no need to use an invalid FILE* for that.

libstdc++-v3/ChangeLog:

	PR libstdc++/98001
	* testsuite/ext/stdio_filebuf/char/79820.cc: Do not pass invalid
	FILE* to constructor.
2020-11-26 11:25:55 +00:00
Jonathan Wakely
127aa17e16 libstdc++: Add new headers to stdc++.h
libstdc++-v3/ChangeLog:

	* include/precompiled/stdc++.h: Add new headers.
	* include/std/stop_token: Include <semaphore> unconditionally.
2020-11-26 11:25:55 +00:00
GCC Administrator
360258daf5 Daily bump. 2020-11-26 00:16:41 +00:00
Jonathan Wakely
dfc537e554 libstdc++: Remove redundant clock conversions in atomic waits
For the case where a timeout is specified using the system_clock we
perform a conversion to the preferred clock (which is either
steady_clock or system_clock itself), wait using __cond_wait_until_impl,
and then check the time by that clock again to see if it was reached.
This is entirely redundant, as we can just call __cond_wait_until_impl
directly. It will wait using the specified clock, and there's no need to
check the time twice. For the no_timeout case this removes two
unnecessary calls to the clock's now() function, and for the timeout
case it removes three calls.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h (__cond_wait_until): Do not
	perform redundant conversions to the same clock.
2020-11-25 18:24:13 +00:00
Jonathan Wakely
7d2a98a727 libstdc++: Encapsulate __gthread_cond_t as std::__condvar
This introduces a new internal utility, std::__condvar, which is a
simplified form of std::condition_variable. It has no dependency on
<chrono> or std::unique_lock, which allows it to be used in
<bits/atomic_wait.h>.

This avoids repeating the #ifdef __GTHREAD_COND_INIT preprocessor
conditions and associated logic for initializing a __gthread_cond_t
correctly. It also encapsulates most of the __gthread_cond_xxx functions
as member functions of __condvar.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h (__cond_wait_until_impl):
	Do not define when _GLIBCXX_HAVE_LINUX_FUTEX is defined. Use
	__condvar and mutex instead of __gthread_cond_t and
	unique_lock<mutex>.
	(__cond_wait_until): Likewise. Fix test for return value of
	__cond_wait_until_impl.
	(__timed_waiters::_M_do_wait_until): Use __condvar instead
	of __gthread_cond_t.
	* include/bits/atomic_wait.h: Remove <bits/unique_lock.h>
	include. Only include <bits/std_mutex.h> if not using futexes.
	(__platform_wait_max_value): Remove unused variable.
	(__waiters::lock_t): Use lock_guard instead of unique_lock.
	(__waiters::_M_cv): Use __condvar instead of __gthread_cond_t.
	(__waiters::_M_do_wait(__platform_wait_t)): Likewise.
	(__waiters::_M_notify()): Likewise. Use notify_one() if not
	asked to notify all.
	* include/bits/std_mutex.h (__condvar): New type.
	* include/std/condition_variable (condition_variable::_M_cond)
	(condition_variable::wait_until): Use __condvar instead of
	__gthread_cond_t.
	* src/c++11/condition_variable.cc (condition_variable): Define
	default constructor and destructor as defaulted.
	(condition_variable::wait, condition_variable::notify_one)
	(condition_variable::notify_all): Forward to corresponding
	member function of __condvar.
2020-11-25 18:24:13 +00:00
Jonathan Wakely
f76cad692a libstdc++: Fix testsuite helper functions [PR 97936]
This fixes a race condition in the util/atomic/wait_notify_util.h header
used by several tests, which should make the tests work properly.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Re-eneable
	test.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/util/atomic/wait_notify_util.h: Fix missed
	notifications by making the new thread wait until the parent
	thread is waiting on the condition variable.
2020-11-25 18:24:12 +00:00
Jonathan Wakely
9d908b7fc4 libstdc++: Fix missing subsumption in std::iterator_traits [PR 97935]
libstdc++-v3/ChangeLog:

	PR libstdc++/97935
	* include/bits/iterator_concepts.h (__detail::__iter_without_category):
	New helper concept.
	(__iterator_traits::__cat): Use __detail::__iter_without_category.
	* testsuite/24_iterators/associated_types/iterator.traits.cc: New test.
2020-11-25 17:22:47 +00:00
Jonathan Wakely
1a8d1f54de libstdc++: Fix test failure on AIX
This fixes a failure on AIX 7.2:

FAIL: 17_intro/names.cc (test for excess errors)
Excess errors:
/home/jwakely/src/gcc/libstdc++-v3/testsuite/17_intro/names.cc:99: error: expected identifier before '(' token
/usr/include/sys/var.h:187: error: expected unqualified-id before '{' token
/usr/include/sys/var.h:187: error: expected ')' before '{' token
/usr/include/sys/var.h:337: error: expected unqualified-id before ';' token
/usr/include/sys/var.h:337: error: expected ')' before ';' token

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Do not test 'v' on AIX.
2020-11-25 17:22:47 +00:00
Jonathan Wakely
a5ccfd0460 libstdc++: Fix silly typos [PR 97936]
libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* include/bits/atomic_wait.h (__platform_wait): Check errno,
	not just the value of EAGAIN.
	(__waiters::__waiters()): Fix name of data member.
2020-11-25 12:16:07 +00:00
Jonathan Wakely
ad9cbcee54 libstdc++: Fix handling of futex wake [PR 97936]
The __platform_wait function is supposed to wait until *addr != old.
The futex syscall checks the initial value and returns EAGAIN if *addr
!= old is already true, which should cause __platform_wait to return.
Instead it loops and keeps doing a futex wait, which keeps returning
EAGAIN.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* include/bits/atomic_wait.h (__platform_wait): Return if futex
	sets EAGAIN.
	* testsuite/30_threads/latch/3.cc: Re-enable test.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
2020-11-25 10:31:55 +00:00
GCC Administrator
1e2c9a2761 Daily bump. 2020-11-25 09:34:01 +00:00
Jonathan Wakely
a3313a2214 libstdc++: Disable failing tests [PR 97936]
These tests are unstable and causing failures due to timeouts. Disable
them until the cause can be found, so that testing doesn't have to wait
for them to timeout.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	PR libstdc++/97944
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Disable.
	Do not require pthreads, but add -pthread when appropriate.
	* testsuite/30_threads/jthread/95989.cc: Likewise.
	* testsuite/30_threads/latch/3.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
2020-11-24 23:41:28 +00:00
Jonathan Wakely
7e0078f864 libstdc++: Run all tests in file
libstdc++-v3/ChangeLog:

	* testsuite/30_threads/jthread/95989.cc: Run all three test
	functions, not just the first one twice.
2020-11-24 14:59:41 +00:00
Jonathan Wakely
4bbd5d0c5f libstdc++: Throw instead of segfaulting in std::thread constructor [PR 67791]
This turns a mysterious segfault into an exception with a more useful
message. If the exception isn't caught, the user sees this instead of
just a segfault:

terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std:🧵 Operation not permitted
Aborted (core dumped)

libstdc++-v3/ChangeLog:

	PR libstdc++/67791
	* src/c++11/thread.cc (thread::_M_start_thread(_State_ptr, void (*)())):
	Check that gthreads is available before calling __gthread_create.
2020-11-24 14:59:40 +00:00
Jonathan Wakely
e253d36214 libstdc++: Use __libc_single_threaded for locale initialization
Most initialization of locales and facets happens before main() during
startup, when the program is likely to only have one thread. By using
the new __gnu_cxx::__is_single_threaded() function instead of checking
__gthread_active_p() we can avoid using pthread_once or atomics for the
common case.

That said, I'm not sure why we don't just use a local static variable
instead, as __cxa_guard_acquire() already optimizes for the
single-threaded case:

  static const bool init = (_S_initialize_once(), true);

I'll revisit that for GCC 12.

libstdc++-v3/ChangeLog:

	* src/c++98/locale.cc (locale::facet::_S_get_c_locale())
	(locale:🆔:_M_id() const): Use __is_single_threaded.
	* src/c++98/locale_init.cc (locale::_S_initialize()):
	Likewise.
2020-11-24 14:59:40 +00:00
GCC Administrator
8e6198d0f8 Daily bump. 2020-11-24 00:16:44 +00:00
Jonathan Wakely
1ccee0fbfa libstdc++: Fix variable declared with wrong type
libstdc++-v3/ChangeLog:

	* include/bits/semaphore_base.h
	(__platform_semaphore::_M_try_acquire_until): Fix type of
	variable.
2020-11-23 18:16:44 +00:00
Stephan Bergmann
0986d3bc62 libstdc++: Fix linker errors due to missing 'inline' keywords
libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h (__thread_relax, __thread_yield):
	Add 'inline'.
2020-11-23 18:15:06 +00:00
Jonathan Wakely
92b47a321e libstdc++: Add configure checks for semaphores
This moves the checks for POSIX semaphores to configure time. As well as
requiring <semaphore.h> and SEM_VALUE_MAX, we also require the
sem_timedwait function. That was only optional in POSIX 2001 (and is
absent on Darwin).

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_GTHREADS): Check for
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE):
	Check autoconf macro instead of defining it here.
2020-11-23 18:12:39 +00:00
Jonathan Wakely
183ae52b22 libstdc++: make atomic waiting depend on gthreads or futexes
libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h: Do not define anything unless
	gthreads or futexes are available.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/semaphore_base.h: Likewise.
	* include/std/semaphore: Likewise.
	* include/bits/atomic_base.h (atomic_flag::wait)
	(atomic_flag::notify_one, atomic_flag::notify_all)
	(__atomic_base<I>::wait, __atomic_base<I>::notify_one)
	(__atomic_base<I>::notify_all, __atomic_base<P*>::wait)
	(__atomic_base<P*>::notify_one, __atomic_base<P*>::notify_all)
	(__atomic_impl::wait, __atomic_impl::notify_one)
	(__atomic_impl::notify_all, __atomic_float::wait)
	(__atomic_float::notify_one, __atomic_float::notify_all)
	(__atomic_ref::wait, __atomic_ref::notify_one)
	(__atomic_ref::notify_all): Only define if gthreads or futexes
	are available.
	* include/std/atomic (atomic::wait, atomic::notify_one)
	(atomic::notify_all): Likewise.
	* include/std/version (__cpp_lib_semaphore): Define
	conditionally.
2020-11-23 18:12:39 +00:00
Jonathan Wakely
fd62daea40 libstdc++: Link tests to libatomic as required [PR 97948]
libstdc++-v3/ChangeLog:

	PR libstdc++/97948
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Add options
	for libatomic.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
2020-11-23 16:06:50 +00:00
GCC Administrator
7a97e2fcf7 Daily bump. 2020-11-22 00:16:24 +00:00
Jonathan Wakely
62d19588b9 libstdc++: Fix atomic waiting for non-linux targets
This fixes some UNRESOLVED tests on (at least) Solaris and Darwin, and
disables some tests that hang forever on Solaris. A proper fix is still
needed.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (atomic_flag::wait): Use correct
	type for __atomic_wait call.
	* include/bits/atomic_timed_wait.h (__atomic_wait_until): Check
	_GLIBCXX_HAVE_LINUX_FUTEX.
	* include/bits/atomic_wait.h (__atomic_notify): Likewise.
	* include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE):
	Only define if SEM_VALUE_MAX or _POSIX_SEM_VALUE_MAX is defined.
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Disable on
	non-linux targes.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
2020-11-21 17:50:13 +00:00
GCC Administrator
82e5048e70 Daily bump. 2020-11-21 00:16:29 +00:00
Thomas Rodgers
83a1beee27 libstdc++: Add C++2a synchronization support
Add support for -
  * atomic_flag::wait/notify_one/notify_all
  * atomic::wait/notify_one/notify_all
  * counting_semaphore
  * binary_semaphore
  * latch

libstdc++-v3/ChangeLog:

	* include/Makefile.am (bits_headers): Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/atomic_base.h (__atomic_flag::wait): Define.
	(__atomic_flag::notify_one): Likewise.
	(__atomic_flag::notify_all): Likewise.
	(__atomic_base<_Itp>::wait): Likewise.
	(__atomic_base<_Itp>::notify_one): Likewise.
	(__atomic_base<_Itp>::notify_all): Likewise.
	(__atomic_base<_Ptp*>::wait): Likewise.
	(__atomic_base<_Ptp*>::notify_one): Likewise.
	(__atomic_base<_Ptp*>::notify_all): Likewise.
	(__atomic_impl::wait): Likewise.
	(__atomic_impl::notify_one): Likewise.
	(__atomic_impl::notify_all): Likewise.
	(__atomic_float<_Fp>::wait): Likewise.
	(__atomic_float<_Fp>::notify_one): Likewise.
	(__atomic_float<_Fp>::notify_all): Likewise.
	(__atomic_ref<_Tp>::wait): Likewise.
	(__atomic_ref<_Tp>::notify_one): Likewise.
	(__atomic_ref<_Tp>::notify_all): Likewise.
	(atomic_wait<_Tp>): Likewise.
	(atomic_wait_explicit<_Tp>): Likewise.
	(atomic_notify_one<_Tp>): Likewise.
	(atomic_notify_all<_Tp>): Likewise.
	* include/bits/atomic_wait.h: New file.
	* include/bits/atomic_timed_wait.h: New file.
	* include/bits/semaphore_base.h: New file.
	* include/std/atomic (atomic<bool>::wait): Define.
	(atomic<bool>::wait_one): Likewise.
	(atomic<bool>::wait_all): Likewise.
	(atomic<_Tp>::wait): Likewise.
	(atomic<_Tp>::wait_one): Likewise.
	(atomic<_Tp>::wait_all): Likewise.
	(atomic<_Tp*>::wait): Likewise.
	(atomic<_Tp*>::wait_one): Likewise.
	(atomic<_Tp*>::wait_all): Likewise.
	* include/std/latch: New file.
	* include/std/semaphore: New file.
	* include/std/version: Add __cpp_lib_semaphore and
	__cpp_lib_latch defines.
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: New test.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Liekwise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
	* testsuite/30_threads/semaphore/1.cc: New test.
	* testsuite/30_threads/semaphore/2.cc: Likewise.
	* testsuite/30_threads/semaphore/least_max_value_neg.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_for.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_posix.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
	* testsuite/30_threads/latch/1.cc: New test.
	* testsuite/30_threads/latch/2.cc: New test.
	* testsuite/30_threads/latch/3.cc: New test.
	* testsuite/util/atomic/wait_notify_util.h: New File.
2020-11-20 14:40:18 -08:00
François Dumont
ba23e045fc libstdc++: Limit memory allocation in stable_sort/inplace_merge (PR 83938)
Reduce memory allocation in stable_sort/inplace_merge algorithms to what is needed
by the implementation.

Co-authored-by: John Chang  <john.chang@samba.tv>

libstdc++-v3/ChangeLog:

	PR libstdc++/83938
	* include/bits/stl_tempbuf.h (get_temporary_buffer): Change __len
	computation in the loop to avoid truncation.
	* include/bits/stl_algo.h:
	(__inplace_merge): Take temporary buffer length from smallest range.
	(__stable_sort): Limit temporary buffer length.
	* testsuite/25_algorithms/inplace_merge/1.cc (test4): New.
	* testsuite/performance/25_algorithms/stable_sort.cc: Test stable_sort
	under different heap memory conditions.
	* testsuite/performance/25_algorithms/inplace_merge.cc: New test.
2020-11-20 22:25:04 +01:00
François Dumont
90bf60c3c2 libstdc++: _Rb_tree code cleanup, remove lambdas
Use new template parameters to replace usage of lambdas to move or not
tree values on copy.

libstdc++-v3/ChangeLog:

	* include/bits/move.h (_GLIBCXX_FWDREF): New.
	* include/bits/stl_tree.h: Adapt to use latter.
	(_Rb_tree<>::_M_clone_node): Add _MoveValue template parameter.
	(_Rb_tree<>::_M_mbegin): New.
	(_Rb_tree<>::_M_begin): Use latter.
	(_Rb_tree<>::_M_copy): Add _MoveValues template parameter.
	* testsuite/23_containers/map/allocator/move_cons.cc: New test.
	* testsuite/23_containers/multimap/allocator/move_cons.cc: New test.
	* testsuite/23_containers/multiset/allocator/move_cons.cc: New test.
	* testsuite/23_containers/set/allocator/move_cons.cc: New test.
2020-11-20 20:56:10 +01:00
Jonathan Wakely
640ebeb336 libstdc++: Remove <memory_resource> dependency from <regex> [PR 92546]
Unlike the other headers that declare alias templates in namespace pmr,
<regex> includes <memory_resource>. That was done because the
pmr::string::const_iterator typedef requires pmr::string to be complete,
which requires pmr::polymorphic_allocator<char> to be complete.

By using __normal_iterator<const char*, pmr::string> instead of the
const_iterator typedef we can avoid the completeness requirement.

This makes <regex> smaller, by not requiring <memory_resource> and its
<shared_mutex> dependency, which depends on <chrono>.  Backporting this
will also help with PR 97876, where <stop_token> ends up being needed by
<regex> via <memory_resource>.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/std/regex (pmr::smatch, pmr::wsmatch): Declare using
	underlying __normal_iterator type, not nested typedef
	basic_string::const_iterator.
2020-11-20 13:06:48 +00:00
GCC Administrator
d62586ee56 Daily bump. 2020-11-20 00:16:40 +00:00
Jonathan Wakely
08b4d32571 libstdc++: Avoid calling undefined __gthread_self weak symbol [PR 95989]
Since glibc 2.27 the pthread_self symbol has been defined in libc rather
than libpthread. Because we only call pthread_self through a weak alias
it's possible for statically linked executables to end up without a
definition of pthread_self. This crashes when trying to call an
undefined weak symbol.

We can use the __GLIBC_PREREQ version check to detect the version of
glibc where pthread_self is no longer in libpthread, and call it
directly rather than through the weak reference.

It would be better to check for pthread_self in libc during configure
instead of hardcoding the __GLIBC_PREREQ check. That would be
complicated by the fact that prior to glibc 2.27 libc.a didn't have the
pthread_self symbol, but libc.so.6 did.  The configure checks would need
to try to link both statically and dynamically, and the result would
depend on whether the static libc.a happens to be installed during
configure (which could vary between different systems using the same
version of glibc). Doing it properly is left for a future date, as that
will be needed anyway after glibc moves all pthread symbols from
libpthread to libc. When that happens we should revisit the whole
approach of using weak symbols for pthread symbols.

For the purposes of std::this_thread::get_id() we call
pthread_self() directly when using glibc 2.27 or later. Otherwise, if
__gthread_active_p() is true then we know the libpthread symbol is
available so we call that. Otherwise, we are single-threaded and just
use ((__gthread_t)1) as the thread ID.

An undesirable consequence of this change is that code compiled prior to
the change might inline the old definition of this_thread::get_id()
which always returns (__gthread_t)1 in a program that isn't linked to
libpthread. Code compiled after the change will use pthread_self() and
so get a real TID. That could result in the main thread having different
thread::id values in different translation units. This seems acceptable,
as there are not expected to be many uses of thread::id in programs
that aren't linked to libpthread.

An earlier version of this patch also changed __gthread_self() to use
__GLIBC_PREREQ(2, 27) and only use the weak symbol for older glibc. Tha
might still make sense to do, but isn't needed by libstdc++ now.

libstdc++-v3/ChangeLog:

	PR libstdc++/95989
	* config/os/gnu-linux/os_defines.h (_GLIBCXX_NATIVE_THREAD_ID):
	Define new macro to get reliable thread ID.
	* include/bits/std_thread.h: (this_thread::get_id): Use new
	macro if it's defined.
	* testsuite/30_threads/jthread/95989.cc: New test.
	* testsuite/30_threads/this_thread/95989.cc: New test.
2020-11-19 21:07:06 +00:00
Jonathan Wakely
5e6a43158d libstdc++: Add missing header to some tests
These tests use std::this_thread::sleep_for without including <thread>.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/async/async.cc: Include <thread>.
	* testsuite/30_threads/future/members/93456.cc: Likewise.
2020-11-19 16:17:33 +00:00
Jonathan Wakely
b204d7722d libstdc++: Move std::thread to a new header
This makes it possible to use std::thread without including the whole of
<thread>. It also makes this_thread::get_id() and this_thread::yield()
available even when there is no gthreads support (e.g. when GCC is built
with --disable-threads or --enable-threads=single).

In order for the std:🧵:id return type of this_thread::get_id() to
be defined, std:thread itself is defined unconditionally. However the
constructor that creates new threads is not defined for single-threaded
builds. The thread::join() and thread::detach() member functions are
defined inline for single-threaded builds and just throw an exception
(because we know the thread cannot be joinable if the constructor that
creates joinable threads doesn't exit).

The thread::hardware_concurrency() member function is also defined
inline and returns 0 (as suggested by the standard when the value "is
not computable or well-defined").

The main benefit for most targets is that other headers such as <future>
do not need to include the whole of <thread> just to be able to create a
std::thread. That avoids including <stop_token> and std::jthread where
not required. This is another partial fix for PR 92546.

This also means we can use this_thread::get_id() and this_thread::yield()
in <stop_token> instead of using the gthread functions directly. This
removes some preprocessor conditionals, simplifying the code.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/Makefile.am: Add new <bits/std_thread.h> header.
	* include/Makefile.in: Regenerate.
	* include/std/future: Include new header instead of <thread>.
	* include/std/stop_token: Include new header instead of
	<bits/gthr.h>.
	(stop_token::_S_yield()): Use this_thread::yield().
	(_Stop_state_t::_M_requester): Change type to std:🧵:id.
	(_Stop_state_t::_M_request_stop()): Use this_thread::get_id().
	(_Stop_state_t::_M_remove_callback(_Stop_cb*)): Likewise.
	Use __is_single_threaded() to decide whether to synchronize.
	* include/std/thread (thread, operator==, this_thread::get_id)
	(this_thread::yield): Move to new header.
	(operator<=>, operator!=, operator<, operator<=, operator>)
	(operator>=, hash<thread::id>, operator<<): Define even when
	gthreads not available.
	* src/c++11/thread.cc: Include <memory>.
	* include/bits/std_thread.h: New file.
	(thread, operator==, this_thread::get_id, this_thread::yield):
	Define even when gthreads not available.
	[!_GLIBCXX_HAS_GTHREADS] (thread::join, thread::detach)
	(thread::hardware_concurrency): Define inline.
2020-11-19 13:36:15 +00:00
Jonathan Wakely
b108faa940 libstdc++: Fix overflow checks to use the correct "time_t" [PR 93456]
I recently added overflow checks to src/c++11/futex.cc for PR 93456, but
then changed the type of the timespec for PR 93421. This meant the
overflow checks were no longer using the right range, because the
variable being written to might be smaller than time_t.

This introduces new typedef that corresponds to the tv_sec member of the
struct being passed to the syscall, and uses that typedef in the range
checks.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	PR libstdc++/93456
	* src/c++11/futex.cc (syscall_time_t): New typedef for
	the type of the syscall_timespec::tv_sec member.
	(relative_timespec, _M_futex_wait_until)
	(_M_futex_wait_until_steady): Use syscall_time_t in overflow
	checks, not time_t.
2020-11-19 13:33:11 +00:00
GCC Administrator
25bb75f841 Daily bump. 2020-11-19 00:16:30 +00:00
Patrick Palka
d4a788c717 libstdc++: Fix ranges::join_view::_Iterator::operator-> [LWG 3500]
This applies the proposed resolution of LWG 3500, which corrects the
return type and constraints of this member function to use the right
iterator type.  Additionally, a nearby local variable is uglified.

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::_Iterator::_M_satisfy): Uglify
	local variable inner.
	(join_view::_Iterator::operator->): Use _Inner_iter instead of
	_Outer_iter in the function signature as per LWG 3500.
	* testsuite/std/ranges/adaptors/join.cc (test08): Test it.
2020-11-18 10:23:57 -05:00
GCC Administrator
4dabb03719 Daily bump. 2020-11-18 00:16:34 +00:00
Jonathan Wakely
1e3e6c700f libstdc++: Revert changes for SYS_clock_gettime64 [PR 93421]
As discussed in the PR, it's incredibly unlikely that a system that
needs to use the SYS_clock_gettime syscall (e.g. glibc 2.16 or older) is
going to define the SYS_clock_gettime64 macro. Ancient systems that need
to use the syscall aren't going to have time64 support.

This reverts the recent changes to try and make clock_gettime syscalls
be compatible with systems that have been updated for time64 (those
changes were wrong anyway as they misspelled the SYS_clock_gettime64
macro). The changes for futex syscalls are retained, because we still
use them on modern systems that might be using time64.

To ensure that the clock_gettime syscalls are safe, configure will fail
if SYS_clock_gettime is needed, and SYS_clock_gettime64 is also defined
(but to a distinct value from SYS_clock_gettime), and the tv_sec member
of timespec is larger than long. This means we will be unable to build
on a hypothetical system where we need the time32 version of
SYS_clock_gettime but where userspace is using a time64 struct timespec.
In the unlikely event that this failure is triggered on any real
systems, we can fix it later. But we probably won't need to.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Fail if struct
	timespec isn't compatible with SYS_clock_gettime.
	* configure: Regenerate.
	* src/c++11/chrono.cc: Revert changes for time64 compatibility.
	Add static_assert instead.
	* src/c++11/futex.cc (_M_futex_wait_until_steady): Assume
	SYS_clock_gettime can use struct timespec.
2020-11-17 22:38:49 +00:00
Jonathan Wakely
ecf65330c1 libstdc++: Fix unconditional definition of __cpp_lib_span in <version> [PR 97869}
The <span> header is empty unless Concepts are supported, but <version>
defines the __cpp_lib_span feature test macro unconditionally. It should
be guarded by the same conditions as in <span>.

libstdc++-v3/ChangeLog:

	PR libstdc++/97869
	* include/precompiled/stdc++.h: Include <coroutine>.
	* include/std/version (__cpp_lib_span): Check __cpp_lib_concepts
	before defining.
2020-11-17 16:13:14 +00:00
Patrick Palka
8661f4faa8 libstdc++: Fix ranges::search_n for random access iterators [PR97828]
My ranges transcription of the std::search_n implementation for random
access iterators missed a crucial part of the algorithm which the
existing tests didn't exercise.  When __remainder is less than __count
at the start of an iteration of the outer while loop, it means we're
continuing a partial match of __count - __remainder elements from the
previous iteration.  If at the end of the iteration we don't complete
this partial match, we need to reset __remainder so that it's only
offset by the size of the most recent partial match before starting the
next iteration.

This patch fixes this appropriately, mirroring how it's done in the
corresponding std::search_n implementation.

libstdc++-v3/ChangeLog:

	PR libstdc++/97828
	* include/bits/ranges_algo.h (__search_n_fn::operator()): Check
	random_access_iterator before using the backtracking
	implementation.  When the backwards scan fails prematurely,
	reset __remainder appropriately.
	* testsuite/25_algorithms/search_n/97828.cc: New test.
2020-11-17 10:28:20 -05:00
GCC Administrator
29c5d9ceb9 Daily bump. 2020-11-17 00:16:27 +00:00
Jonathan Wakely
b2099e9fd9 libstdc++: Fix error shown during Solaris build
Currently this is shown when building libstdc++ on Solaris:

-lrt: open: No such file or directory

The error comes from the make_sunver.pl script which tries to open each
of its arguments. The arguments are passed by this make rule:

	perl ${glibcxx_srcdir}/scripts/make_exports.pl \
	  libstdc++-symbols.ver \
	  $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
	 `echo $(libstdc___la_LIBADD) | \
	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
	 > $@ || (rm -f $@ ; exit 1)

The $(libstdc___la_LIBADD) variable includes $(GLIBCXX_LIBS) which
contains -lrt on Solaris.

This patch adds another sed script to filter -l arguments from the echo
command. In order to reliably match ' -l[^ ]* ' the echo arguments are
quoted and a space added before and after them. This might be overkill
just to remove -lrt from the start of the string, but should be robust
in case other -l arguments are added to $(GLIBCXX_LIBS), or in case the
$(libstdc___la_LIBADD) libraries are reordered.

libstdc++-v3/ChangeLog:

	* src/Makefile.am (libstdc++-symbols.ver-sun): Remove -lrt from
	arguments passed to make_sunver.pl script.
	* src/Makefile.in: Regenerate.
2020-11-16 11:54:22 +00:00
GCC Administrator
cba306519c Daily bump. 2020-11-16 00:16:31 +00:00
Jason Merrill
baf38d2e36 c++: Check abstract type only on object creation. [PR86252]
Abstract checking has been problematic for a while; when I implemented an
earlier issue resolution to do more checking it led to undesirable
instantiations, and so backed some of it out.  During the C++20 process we
decided with P0929R2 that we should go the other way, and only check
abstractness when we're actually creating an object, not when merely forming
an array or function type.  This means that we can remove the machinery for
checking whether a newly complete class makes some earlier declaration
ill-formed.  This change was moved as a DR, so I'm applying it to all
standard levels.  This could be reconsidered if it causes problems, but I
don't expect it to.

The change to the libstdc++ result_of test brings the expected behavior in
line with that for incomplete types, but as in PR97841 I think the libstdc++
handling of incomplete types in this and other type_traits is itself wrong,
so I expect these lines and others to change again before long.

gcc/cp/ChangeLog:

	* decl.c (cp_finish_decl): Only check abstractness on definition.
	(require_complete_types_for_parms): Check abstractness here.
	(create_array_type_for_decl): Not here.
	(grokdeclarator, grokparms, complete_vars): Not here.
	* pt.c (tsubst, tsubst_arg_types, tsubst_function_type): Not here.
	* typeck2.c (struct pending_abstract_type): Remove.
	(struct abstract_type_hasher): Remove.
	(abstract_pending_vars, complete_type_check_abstract): Remove.
	(abstract_virtuals_error_sfinae): Handle arrays.
	* call.c (conv_is_prvalue): Split out from...
	(conv_binds_ref_to_prvalue): ...here.
	(implicit_conversion_1): Rename from implicit_conversion.
	(implicit_conversion): An abstract prvalue is bad.
	(convert_like_internal): Don't complain if expr is already
	error_mark_node.

gcc/testsuite/ChangeLog:

	* g++.dg/other/abstract1.C: Adjust.
	* g++.dg/other/abstract2.C: Adjust.
	* g++.dg/other/abstract4.C: Adjust.
	* g++.dg/other/abstract5.C: Adjust.
	* g++.dg/other/abstract8.C: New test.
	* g++.dg/template/sfinae-dr657.C: Adjust.
	* g++.old-deja/g++.other/decl3.C: Adjust.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/result_of/sfinae_friendly_1.cc: Adjust.
2020-11-15 12:07:13 -05:00
GCC Administrator
77f67db2a4 Daily bump. 2020-11-14 00:16:38 +00:00
Jonathan Wakely
4d039cb9a1 libstdc++: Use custom timespec in system calls [PR 93421]
On 32-bit targets where userspace has switched to 64-bit time_t, we
cannot pass struct timespec to SYS_futex or SYS_clock_gettime, because
the userspace definition of struct timespec will not match what the
kernel expects.

We use the existence of the SYS_futex_time64 or SYS_clock_gettime_time64
macros to imply that userspace *might* have switched to the new timespec
definition.  This is a conservative assumption. It's possible that the
new syscall numbers are defined in the libc headers but that timespec
hasn't been updated yet (as is the case for glibc currently). But using
the alternative struct with two longs is still OK, it's just redundant
if userspace timespec still uses a 32-bit time_t.

We also check that SYS_futex_time64 != SYS_futex so that we don't try
to use a 32-bit tv_sec on modern targets that only support the 64-bit
system calls and define the old macro to the same value as the new one.

We could possibly check #ifdef __USE_TIME_BITS64 to see whether
userspace has actually been updated, but it's not clear if user code
is meant to inspect that or if it's only for libc internal use.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	* src/c++11/chrono.cc [_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL]
	(syscall_timespec): Define a type suitable for SYS_clock_gettime
	calls.
	(system_clock::now(), steady_clock::now()): Use syscall_timespec
	instead of timespec.
	* src/c++11/futex.cc (syscall_timespec): Define a type suitable
	for SYS_futex and SYS_clock_gettime calls.
	(relative_timespec): Use syscall_timespec instead of timespec.
	(__atomic_futex_unsigned_base::_M_futex_wait_until): Likewise.
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Likewise.
2020-11-13 23:08:35 +00:00
Jonathan Wakely
b8d36dcc91 libstdc++: Remove redundant overflow check for futex timeout [PR 93456]
The relative_timespec function already checks for the case where the
specified timeout is in the past, so the difference can never be
negative. That means we dn't need to check if it's more negative than
the minimum time_t value.

libstdc++-v3/ChangeLog:

	PR libstdc++/93456
	* src/c++11/futex.cc (relative_timespec): Remove redundant check
	negative values.
	* testsuite/30_threads/future/members/wait_until_overflow.cc: Moved to...
	* testsuite/30_threads/future/members/93456.cc: ...here.
2020-11-13 23:08:34 +00:00
Jonathan Wakely
91004436da libstdc++: Avoid more 32-bit time_t overflows in futex calls
This fixes another overflow in code converting a std::chrono::seconds
duration to a time_t. This time in the new code using a futex wait with
an absolute timeout (so this one doesn't need to be backported to the
release branches).

A timeout after the epochalypse would overflow the tv_sec field,
producing an incorrect value. If that incorrect value happened to be
negative, the syscall would return with EINVAL and then the caller would
keep retrying, spinning until the timeout was reached.  If the value
happened to be positive, we would wake up too soon and incorrectly
report a timeout

libstdc++-v3/ChangeLog:

	* src/c++11/futex.cc (relative_timespec): Add [[unlikely]]
	attributes.
	(__atomic_futex_unsigned_base::_M_futex_wait_until)
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Check for overflow.
	* testsuite/30_threads/future/members/wait_until_overflow.cc:
	New test.
2020-11-13 19:11:07 +00:00
Jonathan Wakely
e7e0eeeb6e libstdc++: Avoid 32-bit time_t overflows in futex calls
The existing code doesn't check whether the chrono::seconds value is out
of range of time_t. When using a timeout before the epoch (with a
negative value) subtracting the current time (as time_t) and then
assigning it to a time_t can overflow to a large positive value. This
means that we end up waiting several years even though the specific
timeout was in the distant past.

We do have a check for negative timeouts, but that happens after the
conversion to time_t so happens after the overflow.

The conversion to a relative timeout is done in two places, so this
factors it into a new function and adds the overflow checks there.

libstdc++-v3/ChangeLog:

	* src/c++11/futex.cc (relative_timespec): New function to
	create relative time from two absolute times.
	(__atomic_futex_unsigned_base::_M_futex_wait_until)
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Use relative_timespec.
2020-11-13 17:19:12 +00:00
Jonathan Wakely
8c4e33d203 libstdc++: Add -pthread options to std::future polling test
For linux targets this test doesn't need -lpthread because it only uses
atomics, but for all other targets std::call_once still needs pthreads.
Add the necessary test directives to make that work.

The timings in this test might be too fragile or too target-specific, so
it might need to be adjusted in future, or restricted to only run on
specific targets. For now I've increased the allowed ratio between
wait_for calls before and after the future is made ready, because it was
failing with -O3 -march=native sometimes.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/future/members/poll.cc: Require gthreads
	and add -pthread for targets that require it. Relax required
	ratio of wait_for calls before/after the future is ready.
2020-11-13 11:01:24 +00:00
GCC Administrator
a5a115258a Daily bump. 2020-11-13 00:16:35 +00:00
Jonathan Wakely
93fc477468 libstdc++: Optimise std::future::wait_for and fix futex polling
To poll a std::future to see if it's ready you have to call one of the
timed waiting functions. The most obvious way is wait_for(0s) but this
was previously very inefficient because it would turn the relative
timeout to an absolute one by calling system_clock::now(). When the
relative timeout is zero (or less) we're obviously going to get a time
that has already passed, but the overhead of obtaining the current time
can be dozens of microseconds. The alternative is to call wait_until
with an absolute timeout that is in the past. If you know the clock's
epoch is in the past you can use a default constructed time_point.
Alternatively, using some_clock::time_point::min() gives the earliest
time point supported by the clock, which should be safe to assume is in
the past. However, using a futex wait with an absolute timeout before
the UNIX epoch fails and sets errno=EINVAL. The new code using futex
waits with absolute timeouts was not checking for this case, which could
result in hangs (or killing the process if the libray is built with
assertions enabled).

This patch checks for times before the epoch before attempting to wait
on a futex with an absolute timeout, which fixes the hangs or crashes.
It also makes it very fast to poll using an absolute timeout before the
epoch (because we skip the futex syscall).

It also makes future::wait_for avoid waiting at all when the relative
timeout is zero or less, to avoid the unnecessary overhead of getting
the current time. This makes polling with wait_for(0s) take only a few
cycles instead of dozens of milliseconds.

libstdc++-v3/ChangeLog:

	* include/std/future (future::wait_for): Do not wait for
	durations less than or equal to zero.
	* src/c++11/futex.cc (_M_futex_wait_until)
	(_M_futex_wait_until_steady): Do not wait for timeouts before
	the epoch.
	* testsuite/30_threads/future/members/poll.cc: New test.
2020-11-12 23:47:04 +00:00
Jonathan Wakely
d21776ef90 libstdc++: Simplify __numeric_traits definition
This changes the __numeric_traits primary template to assume its
argument is an integer type. For the three floating point types that are
supported by __numeric_traits_floating an explicit specialization of
__numeric_traits chooses the right base class.

This improves the failure mode for using __numeric_traits with an
unsupported type. Previously it would use __numeric_traits_floating as
the base class, and give somewhat obscure errors for trying to access
the static data members. Now it will use __numeric_traits_integer which
has a static_assert to check for supported types.

As a side effect of this change there is no need to instantiate
__conditional_type to decide which base class to use.

libstdc++-v3/ChangeLog:

	* include/ext/numeric_traits.h (__numeric_traits): Change
	primary template to always derive from __numeric_traits_integer.
	(__numeric_traits<float>, __numeric_traits<double>)
	(__numeric_traits<long double>): Add explicit specializations.
2020-11-12 14:36:39 +00:00
Jonathan Wakely
7f851c3341 libstdc++: Fix __numeric_traits_integer<__int20> [PR 97798]
The expression used to calculate the maximum value for an integer type
assumes that the number of bits in the value representation is always
sizeof(T) * CHAR_BIT. This is not true for the __int20 type on msp430,
which has only 20 bits in the value representation but 32 bits in the
object representation. This causes an integer overflow in a constant
expression, which is ill-formed.

This problem was already solved by DJ for std::numeric_limits<__int20>
by generalizing the helper macros to use a specified number of bits
instead of assuming sizeof(T) * CHAR_BIT. Then the INT_N_n types can
specify the number of bits using the __GLIBCXX_BITSIZE_INT_N_n macros
that the compiler defines.

I'm using a slightly different approach here. I've replaced the helper
macros entirely, and just expanded the calculations in the initializers
for the static data members. By reordering the data members we can reuse
__is_signed and __digits in the other initializers. This removes the
repetition of expanding __glibcxx_signed(T) and __glibcxx_digits(T)
multiple times in each initializer.

The __is_integer_nonstrict trait now defines a new constant, __width,
which is sizeof(T) * CHAR_BIT by default (defined as an enumerator so
that no storage is needed for a static data member). By specializing
__is_integer_nonstrict for the INT_N types that have padding bits, we
can provide the correct width via the __GLIBCXX_BITSIZE_INT_N_n macros.

libstdc++-v3/ChangeLog:

	PR libstdc++/97798
	* include/ext/numeric_traits.h (__glibcxx_signed)
	(__glibcxx_digits, __glibcxx_min, __glibcxx_max): Remove
	macros.
	(__is_integer_nonstrict::__width): Define new constant.
	(__numeric_traits_integer): Define constants in terms of each
	other and __is_integer_nonstrict::__width, rather than the
	removed macros.
	(_GLIBCXX_INT_N_TRAITS): Macro to define explicit
	specializations for non-standard integer types.
2020-11-12 12:10:10 +00:00
GCC Administrator
0f5f9ed5e5 Daily bump. 2020-11-12 00:16:39 +00:00
Jonathan Yong
505ea90904 libstdc++: Exclude cygwin and mingw from linker relro support
PE format does not have ELF style relro linker support, exclude
from checking. If the host linker supports ELF format, configure
may get confused.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Exclude
	cygwin and mingw from relro linker test.
	* configure: Regenerate.
2020-11-11 15:36:05 +00:00
Paul Scharnofske
0ebaea3b66 libstdc++: Assigning to a joinable std::jthread calls std::terminate
Move assigning to a std::jthread that represents a thread of execution
needs to send a stop request and join that running thread. Otherwise the
std::thread data member will terminate in its assignment operator.

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

libstdc++-v3/ChangeLog:

	* include/std/thread (jthread::operator=(jthread&&)): Transfer
	any existing state to a temporary that will request a stop and
	then join.
	* testsuite/30_threads/jthread/jthread.cc: Test move assignment.
2020-11-11 11:13:31 +00:00
Jonathan Wakely
43f9e5aff0 libstdc++: Use helper type for checking thread ID
This encapsulates the storing and checking of the thread ID into a class
type, so that the macro _GLIBCXX_HAS_GTHREADS is only checked in one
place. The code doing the checks just calls member functions of the new
type, without caring whether that really does any work or not.

libstdc++-v3/ChangeLog:

	* include/std/stop_token (_Stop_state_t::_M_requester): Define
	new struct with members to store and check the thread ID.
	(_Stop_state_t::_M_request_stop()): Use _M_requester._M_set().
	(_Stop_state_t::_M_remove_callback(_Stop_cb*)): Use
	_M_requester._M_is_current_thread().
2020-11-11 11:13:31 +00:00
Jonathan Wakely
ecba8547dd libstdc++: Implement std::emit_on_flush etc.
This adds the manipulators for use with basic_osyncstream. In order to
detect when an arbitrary basic_ostream<C,T> is the base class of a
basic_syncbuf<C,T,A> object, introduce a new intermediate base class
that stores the data members. The new base class stores a pointer and
two bools, which wastes (sizeof(void*) - 2) bytes of padding. It would
be possible to use the two least significant bits of the pointer for the
two bools, at least for targets where alignof(basic_streambuf) > 2, but
that's left as a possible change for a future date.

Also define basic_syncbuf::overflow to override the virtual function in
the base class, so that single characters can be inserted into the
stream buffer. Previously the default basic_streambuf::overflow
implementation was used, which drops the character on the floor.

libstdc++-v3/ChangeLog:

	* include/std/ostream (__syncbuf_base): New class template.
	(emit_on_flush, noemit_on_flush, flush_emit): New manipulators.
	* include/std/syncstream (basic_syncbuf): Derive from
	__syncbuf_base instead of basic_streambuf.
	(basic_syncbuf::operator=): Remove self-assignment check.
	(basic_syncbuf::swap): Remove self-swap check.
	(basic_syncbuf::emit): Do not skip pubsync() call if sequence
	is empty.
	(basic_syncbuf::sync): Remove no-op pubsync on stringbuf.
	(basic_syncbuf::overflow): Define override.
	* testsuite/27_io/basic_syncstream/basic_ops/1.cc: Test
	basic_osyncstream::put(char_type).
	* testsuite/27_io/basic_ostream/emit/1.cc: New test.
2020-11-11 00:19:40 +00:00
GCC Administrator
bb6226419f Daily bump. 2020-11-11 00:16:36 +00:00
Jonathan Wakely
5dfbc52264 libstdc++: Avoid bad_alloc exceptions when changing locales
For the --enable-clocale=generic configuration, the current code can
fail with a bad_alloc exception. This patch uses the nothrow version of
operator new and reports allocation failures by setting failbit in the
iostate variable.

	* config/locale/generic/c_locale.cc (__set_C_locale()): New function
	to set the "C" locale and return the name of the previous locale.
	(__convert_to_v<float>, __convert_to_v<double>)
	(__convert_to_v<long double>): Use __set_C_locale and set failbit on
	error.
2020-11-10 20:33:29 +00:00
Jonathan Wakely
f7c41c572b libstdc++: Reorder constructors in <sstream>
This groups all the constructors together, consistent with the synopses
in the C++20 standard.

libstdc++-v3/ChangeLog:

	* include/std/sstream (basic_stringbug, basic_istringstream)
	(basic_ostringstream, basic_stringstream): Reorder C++20
	constructors to be declared next to other constructors.
2020-11-10 19:22:48 +00:00
Jonathan Wakely
95cb0fc8c5 libstdc++: Add remaining C++20 additions to <sstream> [P0408R7]
This adds the new overloads of basic_stringbuf::str, and the
corresponding overloads to basic_istringstream, basic_ostringstream and
basic_stringstream.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten patterns.
	(GLIBCXX_3.4.29): Export new symbols.
	* include/bits/alloc_traits.h (__allocator_like): New concept.
	* include/std/sstream (basic_stringbuf::swap): Add exception
	specification.
	(basic_stringbuf::str() const): Add ref-qualifier. Use new
	_M_high_mark function.
	(basic_stringbuf::str(const SAlloc&) const): Define new function.
	(basic_stringbuf::str() &&): Likewise.
	(basic_stringbuf::str(const basic_string<C,T,SAlloc>&)):
	Likewise.
	(basic_stringbuf::str(basic_string<C,T,Alloc>&&)): Likewise.
	(basic_stringbuf::view() const): Use _M_high_mark.
	(basic_istringstream::str, basic_ostringstream::str)
	(basic_stringstream::str): Define new overloads.
	* src/c++20/sstream-inst.cc (basic_stringbuf::str)
	(basic_istringstream::str, basic_ostringstream::str)
	(basic_stringstream::str): Explicit instantiation definitions
	for new overloads.
	* testsuite/27_io/basic_istringstream/view/char/1.cc: Add more
	checks.
	* testsuite/27_io/basic_istringstream/view/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/basic_ostringstream/view/char/1.cc:
	Likewise.
	* testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/basic_stringstream/view/char/1.cc:
	Likewise.
	* testsuite/27_io/basic_stringstream/view/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/basic_istringstream/str/char/2.cc: New test.
	* testsuite/27_io/basic_istringstream/str/wchar_t/2.cc: New test.
	* testsuite/27_io/basic_ostringstream/str/char/3.cc: New test.
	* testsuite/27_io/basic_ostringstream/str/wchar_t/3.cc: New test.
	* testsuite/27_io/basic_stringbuf/str/char/4.cc: New test.
	* testsuite/27_io/basic_stringbuf/str/wchar_t/4.cc: New test.
	* testsuite/27_io/basic_stringstream/str/char/5.cc: New test.
	* testsuite/27_io/basic_stringstream/str/wchar_t/5.cc.cc: New test.
2020-11-10 19:22:47 +00:00
Jonathan Wakely
ced70ebaa3 libstdc++: Fix more unspecified comparisons to null pointer [PR 97415]
This adds some more null checks to avoid a relational comparison with a
null pointer, similar to 78198b6021.

libstdc++-v3/ChangeLog:

	PR libstdc++/97415
	* include/std/sstream (basic_stringbuf::_M_update_egptr)
	(basic_stringbuf::__xfer_bufptrs::__xfer_bufptrs): Check for
	null before comparing pointers.
2020-11-10 19:21:55 +00:00
GCC Administrator
2bee28dd41 Daily bump. 2020-11-10 00:16:24 +00:00
François Dumont
6db082477a libstdc++: Remove <debug/array>
Add _GLIBCXX_ASSERTIONS assert in normal std::array and remove __gnu_debug::array
implementation.

libstdc++-v3/ChangeLog:

	* include/debug/array: Remove.
	* include/Makefile.am: Remove <debug/array>.
	* include/Makefile.in: Regenerate.
	* include/experimental/functional: Adapt.
	* include/std/array: Move to _GLIBCXX_INLINE_VERSION namespace.
	* include/std/functional: Adapt.
	* include/std/span: Adapt.
	* testsuite/23_containers/array/debug/back1_neg.cc:
	Remove dg-require-debug-mode. Add -D_GLIBCXX_ASSERTIONS option.
	* testsuite/23_containers/array/debug/back2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc:
	Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc:
	Likewise.
	* testsuite/23_containers/array/element_access/60497.cc
	* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
	Remove.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc
	* testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc
	* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
2020-11-09 21:20:01 +01:00
François Dumont
38b17c27ce libstdc++: Make _GLIBCXX_DEBUG checks constexpr compatible
libstdc++-v3/ChangeLog:

	* include/debug/assertions.h (__glibcxx_requires_non_empty_range):
	Remove __builtin_expect.
	(__glibcxx_requires_subscript): Likewise.
	(__glibcxx_requires_nonempty): Likewise.
	* include/debug/formatter.h (__check_singular): Add C++11 constexpr
	qualification.
	* include/debug/helper_functions.h (__check_singular): Likewise. Skip
	check if constant evaluated.
	(__valid_range): Do not skip check if constant evaluated.
	* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Add
	__builtin_expect.
	(_GLIBCXX_DEBUG_VERIFY_AT_F): Use __glibcxx_assert_1.
	* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/char/front_back_constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
	New test.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc: New test.
2020-11-09 21:11:13 +01:00
Jonathan Wakely
b2b8516373 libstdc++: Improve comment on _Power_of_2 helper function
libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (__detail::_Power_of_2):
	Document that true result for zero is intentional.
2020-11-09 14:54:29 +00:00
Jonathan Wakely
ff4bfb1553 libstdc++: Remove redundant check for zero in std::__popcount
The popcount built-ins work fine for zero, so there's no need to check
for it.

libstdc++-v3/ChangeLog:

	* include/std/bit (__popcount): Remove redundant check for zero.
2020-11-09 14:54:29 +00:00
Jonathan Wakely
0af3930a49 libstdc++: Use 'inline' consistently in std::exception_ptr [PR 97729]
With PR c++/67453 fixed we can rely on the 'used' attribute to emit
inline constructors and destructors in libsupc++/eh_ptr.cc. This means
we don't need to suppress the 'inline' keyword on them in that file, and
don't need to force 'always_inline' on them in other files.

libstdc++-v3/ChangeLog:

	PR libstdc++/97729
	* libsupc++/exception_ptr.h (exception_ptr::exception_ptr())
	(exception_ptr::exception_ptr(const exception_ptr&))
	(exception_ptr::~exception_ptr()): Remove 'always_inline'
	attributes. Use 'inline' unconditionally.
2020-11-09 14:28:38 +00:00
Jonathan Wakely
99bf3a817b libstdc++: Include <typeinfo> even for -fno-rtti [PR 97758]
The std::function code now uses std::type_info* even when RTTI is
disabled, so it should include <typeinfo> unconditionally. Without this,
Clang can't compile <functional> with -fno-rtti (it works with GCC
because std::type_info gets declared automatically by the compiler).

libstdc++-v3/ChangeLog:

	PR libstdc++/97758
	* include/bits/std_function.h [!__cpp_rtti]: Include <typeinfo>.
2020-11-09 14:28:37 +00:00
GCC Administrator
2da7ee050c Daily bump. 2020-11-08 00:16:31 +00:00
Liu Hao
7fc0f78c3f libsupc++: Make the destructor parameter to __cxa_thread_atexit() use the __thiscall calling convention for i686-w64-mingw32
The mingw-w64 implementations of `__cxa_thread_atexit()` and `__cxa_atexit()` have been
using `__thiscall` since two years ago. Using the default calling convention (which is
`__cdecl`) causes crashes as explained in PR83562.

Calling conventions have no effect on x86_64-w64-mingw32.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83562
Reference: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/crt/cxa_thread_atexit.c
Reference: f3e0fbb40c/
Reference: https://github.com/msys2/MINGW-packages/issues/7071
Signed-off-by: Liu Hao <lh_mouse@126.com>

    2020-10-08  Liu Hao  <lh_mouse@126.com>

	libstdc++-v3:
	* libsupc++/cxxabi.h: (__cxa_atexit): mark with _GLIBCXX_CDTOR_CALLABI
	(__cxa_thread_atexit): ditto
	* libsupc++/atexit_thread.cc: (__cxa_atexit): mark with
	_GLIBCXX_CDTOR_CALLABI
	(__cxa_thread_atexit): ditto
	(elt): ditto
2020-11-07 02:50:43 +00:00
GCC Administrator
44cab2d8fd Daily bump. 2020-11-07 00:16:39 +00:00
Jonathan Wakely
887515acd2 libstdc++: Fix symbol version conflict in linker script
The change in r11-4748-50b840ac5e1d6534e345c3fee9a97ae45ced6bc7 causes
a build error on Solaris, due to the new explicit instantiation matching
patterns for two different symbol versions.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten up patterns
	for basic_stringbuf that refer to __xfer_bufptrs.
2020-11-06 20:14:03 +00:00
GCC Administrator
0cfd9109e5 Daily bump. 2020-11-06 00:16:34 +00:00
Marek Polacek
5b2003105b c++: Implement -Wvexing-parse [PR25814]
This patch implements the -Wvexing-parse warning to warn about the
sneaky most vexing parse rule in C++: the cases when a declaration
looks like a variable definition, but the C++ language requires it
to be interpreted as a function declaration.  This warning is on by
default (like clang++).  From the docs:

  void f(double a) {
    int i();        // extern int i (void);
    int n(int(a));  // extern int n (int);
  }

  Another example:

  struct S { S(int); };
  void f(double a) {
    S x(int(a));   // extern struct S x (int);
    S y(int());    // extern struct S y (int (*) (void));
    S z();         // extern struct S z (void);
  }

You can find more on this in [dcl.ambig.res].

I spent a fair amount of time on fix-it hints so that GCC can recommend
various ways to resolve such an ambiguity.  Sometimes that's tricky.
E.g., suggesting default-initialization when the class doesn't have
a default constructor would not be optimal.  Suggesting {}-init is also
not trivial because it can use an initializer-list constructor if no
default constructor is available (which ()-init wouldn't do).  And of
course, pre-C++11, we shouldn't be recommending {}-init at all.

I also uncovered a bug in cp_parser_declarator, where we were setting
*parenthesized_p to true despite the comment saying the exact opposite.

gcc/c-family/ChangeLog:

	PR c++/25814
	* c.opt (Wvexing-parse): New option.

gcc/cp/ChangeLog:

	PR c++/25814
	* cp-tree.h (enum cp_tree_index): Add CPTI_EXPLICIT_VOID_LIST.
	(explicit_void_list_node): Define.
	(PARENTHESIZED_LIST_P): New macro.
	(struct cp_declarator): Add function::parens_loc.
	* decl.c (cxx_init_decl_processing): Initialize explicit_void_list_node.
	(grokparms): Also break when explicit_void_list_node.
	* parser.c (make_call_declarator): New location_t parameter.  Use it
	to set declarator->u.function.parens_loc.
	(cp_parser_lambda_declarator_opt): Pass UNKNOWN_LOCATION to
	make_call_declarator.
	(warn_about_ambiguous_parse): New function.
	(cp_parser_init_declarator): Call warn_about_ambiguous_parse.
	(cp_parser_declarator): Set *parenthesized_p to false rather than to
	true.
	(cp_parser_direct_declarator): Create a location for the function's
	parentheses and pass it to make_call_declarator.
	(cp_parser_parameter_declaration_clause): Return explicit_void_list_node
	for (void).
	(cp_parser_parameter_declaration_list): Set PARENTHESIZED_LIST_P
	in the parameters tree.

gcc/ChangeLog:

	PR c++/25814
	* doc/invoke.texi: Document -Wvexing-parse.

gcc/testsuite/ChangeLog:

	PR c++/25814
	* g++.dg/cpp2a/fn-template16.C: Add a dg-warning.
	* g++.dg/cpp2a/fn-template7.C: Likewise.
	* g++.dg/lookup/pr80891-5.C: Likewise.
	* g++.dg/lto/pr79050_0.C: Add extern.
	* g++.dg/lto/pr84805_0.C: Likewise.
	* g++.dg/parse/pr58898.C: Add a dg-warning.
	* g++.dg/template/scope5.C: Likewise.
	* g++.old-deja/g++.brendan/recurse.C: Likewise.
	* g++.old-deja/g++.jason/template4.C: Likewise.
	* g++.old-deja/g++.law/arm4.C: Likewise.
	* g++.old-deja/g++.mike/for2.C: Likewise.
	* g++.old-deja/g++.other/local4.C: Likewise.
	* g++.old-deja/g++.pt/crash3.C: Likewise.
	* g++.dg/warn/Wvexing-parse.C: New test.
	* g++.dg/warn/Wvexing-parse2.C: New test.
	* g++.dg/warn/Wvexing-parse3.C: New test.
	* g++.dg/warn/Wvexing-parse4.C: New test.
	* g++.dg/warn/Wvexing-parse5.C: New test.
	* g++.dg/warn/Wvexing-parse6.C: New test.
	* g++.dg/warn/Wvexing-parse7.C: New test.

libstdc++-v3/ChangeLog:

	PR c++/25814
	* testsuite/20_util/reference_wrapper/lwg2993.cc: Add a dg-warning.
	* testsuite/25_algorithms/generate_n/87982_neg.cc: Likewise.
2020-11-05 15:55:14 -05:00
Jonathan Wakely
d16d45655d libstdc++: Fix typo in ChangeLog entry 2020-11-05 19:35:34 +00:00
Jonathan Wakely
cdd2d448d8 libstdc++: Fix constraints on std::optional comparisons [PR 96269]
The relational operators for std::optional were using the wrong types
in the declval expressions used to constrain them. Instead of using
const lvalues they were using non-const rvalues, which meant that a type
might satisfy the constraints but then give an error when the function
body was instantiated.

libstdc++-v3/ChangeLog:

	PR libstdc++/96269
	* include/std/optional (operator==, operator!=, operator<)
	(operator>, operator<=, operator>=): Fix types used in
	SFINAE constraints.
	* testsuite/20_util/optional/relops/96269.cc: New test.
2020-11-05 19:09:22 +00:00
Jonathan Wakely
2f93a2a03a libstdc++: Use non-throwing increment in recursive_directory_iterator [PR 97731]
As described in the PR, the recursive_directory_iterator constructor
calls advance(ec), but ec is a pointer so it calls _Dir::advance(bool).
The intention was to either call advance() or advance(*ec) depending
whether the pointer is null or not.

This fixes the bug and renames the parameter to ecptr to make similar
mistakes less likely in future.

libstdc++-v3/ChangeLog:

	PR libstdc++/97731
	* src/filesystem/dir.cc (recursive_directory_iterator): Call the
	right overload of _Dir::advance.
	* testsuite/experimental/filesystem/iterators/97731.cc: New test.
2020-11-05 18:01:26 +00:00
Jonathan Wakely
710508c7b1 libstdc++: Fix multiple definitions of std::exception_ptr functions [PR 97729]
This fixes some multiple definition errors caused by the changes for
PR libstdc++/90295. The previous solution for inlining the members of
std::exception_ptr but still exporting them from the library was to
suppress the 'inline' keyword on those functions when compiling
libsupc++/eh_ptr.cc, so they get defined in that file. That produces ODR
violations though, because there are now both inline and non-inline
definitions in the library, due to the use of std::exception_ptr in
other files sucg as src/c++11/future.cc.

The new solution is to define all the relevant members as 'inline'
unconditionally, but use __attribute__((used)) to cause definitions to
be emitted in libsupc++/eh_ptr.cc as before. This doesn't quite work
however, because PR c++/67453 means the attribute is ignored on
constructors and destructors. As a workaround, the old solution
(conditionally inline) is still used for those members, but they are
given the always_inline attribute so that they aren't emitted in
src/c++11/future.o as inline definitions.

libstdc++-v3/ChangeLog:

	PR libstdc++/97729
	* include/std/future (__basic_future::_M_get_result): Use
	nullptr for null pointer constant.
	* libsupc++/eh_ptr.cc (operator==, operator!=): Remove
	definitions.
	* libsupc++/exception_ptr.h (_GLIBCXX_EH_PTR_USED): Define
	macro to conditionally add __attribute__((__used__)).
	(operator==, operator!=, exception_ptr::exception_ptr())
	(exception_ptr::exception_ptr(const exception_ptr&))
	(exception_ptr::~exception_ptr())
	(exception_ptr::operator=(const exception_ptr&))
	(exception_ptr::swap(exception_ptr&)): Always define as
	inline. Add macro to be conditionally "used".
2020-11-05 18:01:25 +00:00
Jonathan Wakely
50b840ac5e libstdc++: Export basic_stringbuf constructor [PR 97729]
libstdc++-v3/ChangeLog:

	PR libstdc++/97729
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Add exports.
	* src/c++20/sstream-inst.cc (basic_stringbuf): Instantiate
	private constructor taking __xfer_bufptrs.
2020-11-05 18:01:25 +00:00
Jonathan Wakely
432258be4f libstdc++: Fix new <sstream> constructors
- Add a missing 'explicit' to a basic_stringbuf constructor.
- Set up the get/put area pointers in the constructor from strings using
  different allocator types.
- Remove public basic_stringbuf::__sv_type alias.
- Do not construct temporary basic_string objects with a
  default-constructed allocator.

Also, change which basic_string constructor is used, as a minor
compile-time optimization. Constructing from a basic_string_view
requires more work from the compiler, so just use a pointer and length.

libstdc++-v3/ChangeLog:

	* include/std/sstream (basic_stringbuf(const allocator_type&):
	Add explicit.
	(basic_stringbuf(const basic_string<C,T,SA>&, openmode, const A&)):
	Call _M_stringbuf_init. Construct _M_string from pointer and length
	to avoid constraint checks for string view.
	(basic_stringbuf::view()): Make __sv_type alias local to the
	function.
	(basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&)):
	Pass string to _M_streambuf instead of constructing a temporary
	with the wrong allocator.
	(basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&)):
	Likewise.
	(basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&)):
	Likewise.
	* src/c++20/sstream-inst.cc: Use string_view and wstring_view
	typedefs in explicit instantiations.
	* testsuite/27_io/basic_istringstream/cons/char/1.cc: Add more
	tests for constructors.
	* testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/char/2.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise.
2020-11-05 13:31:32 +00:00
Jonathan Wakely
cbc3f0bcc0 libstdc++: Adjust whitespace in <sstream>
libstdc++-v3/ChangeLog:

	* include/std/sstream: Adjust whitespace.
2020-11-05 13:31:32 +00:00
GCC Administrator
35c125cb6a Daily bump. 2020-11-05 00:16:36 +00:00
Jonathan Wakely
8f565d255a libstdc++: Fix default mode of new basic_stringstream constructor [PR 97719]
libstdc++-v3/ChangeLog:

	PR libstdc++/97719
	* include/std/sstream (basic_stringstream(string_type&&, openmode)):
	Fix default argument.
	* testsuite/27_io/basic_stringstream/cons/char/97719.cc: New test.
2020-11-04 23:41:02 +00:00
Jonathan Wakely
9c1125c121 libstdc++: Fix test failure with --disable-linux-futex
As noted in PR 96817 this new test fails if the library is built without
futexes. That's expected of course, but we might as well fail more
obviously than a deadlock that eventually times out.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Fail fail if the library is
	configured to not use futexes.
2020-11-04 15:30:54 +00:00
Jonathan Wakely
e0af865ab9 libstdc++: Define new C++17 std::search overload for Parallel Mode [PR 94971]
libstdc++-v3/ChangeLog:

	PR libstdc++/94971
	* include/bits/stl_algo.h (search(FIter, FIter, const Searcher):
	Adjust #if condition.
	* include/parallel/algo.h (search(FIter, FIter, const Searcher&):
	Define new overload for C++17.
2020-11-04 13:36:32 +00:00
Jonathan Wakely
3ef33e756a libstdc++: Document istreambuf_iterator base class change [PR 92285]
libstdc++-v3/ChangeLog:

	PR libstdc++/92285
	* doc/xml/manual/evolution.xml: Document change to base class.
	* doc/html/manual/api.html: Regenerate.
2020-11-04 12:46:52 +00:00
Jonathan Wakely
24366207b7 libstdc++: Fix constant expressions in std::uniform_int_distribution
Clang and EDG say the class member access expressions __urng.min() and
__urng.max() are not constant expressions, because the object expression
__urng is not usable in a constant expresion. Use a qualified-id to call
those static member functions instead.

Co-authored-by: Stephan Bergmann <sbergman@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (uniform_int_distribution::_S_nd):
	Use qualified-id to refer to static member functions.
2020-11-04 10:36:45 +00:00
GCC Administrator
fd2325ea60 Daily bump. 2020-11-04 00:16:41 +00:00
Jonathan Wakely
e1276e3342 libstdc++: Ensure std::lock_guard is declared
libstdc++-v3/ChangeLog:

	* include/std/syncstream: Include <bits/std_mutex.h>
	unconditionally.
2020-11-03 21:56:44 +00:00
François Dumont
12d0512305 libstdc++: Add mising gnu-versioned-namespace symbols
libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu-versioned-namespace.ver:
	Add __istream_extract and _Safe_local_iterator_base::_M_attach_single
	symbols.
2020-11-03 22:01:55 +01:00
Jonathan Wakely
9f925f3b19 libstdc++: Refactor std::call_once internals
This separates the definition of std::__call_proxy into two funcions,
one for TLS and one for non-TLS, to make them easier to read. It also
replaces the __get_once_functor_lock_ptr() internal helper with a new
set_lock_ptr(unique_lock<mutex>*) function so that __once_proxy doesn't
need to call it twice.

libstdc++-v3/ChangeLog:

	* src/c++11/mutex.cc [_GLIBCXX_HAVE_TLS] (__once_proxy): Define
	separately for TLS targets.
	[!_GLIBCXX_HAVE_TLS] (__get_once_functor_lock_ptr): Replace with ...
	(set_lock_ptr): ... this. Set new value and return previous
	value.
	[!_GLIBCXX_HAVE_TLS] (__set_once_functor_lock_ptr): Adjust to
	use set_lock_ptr.
	[!_GLIBCXX_HAVE_TLS] (__once_proxy): Likewise.
2020-11-03 20:03:16 +00:00
Jonathan Wakely
93e79ed391 libstdc++: Rewrite std::call_once to use futexes [PR 66146]
The current implementation of std::call_once uses pthread_once, which
only meets the C++ requirements when compiled with support for
exceptions. For most glibc targets and all non-glibc targets,
pthread_once does not work correctly if the init_routine exits via an
exception. The pthread_once_t object is left in the "active" state, and
any later attempts to run another init_routine will block forever.

This change makes std::call_once work correctly for Linux targets, by
replacing the use of pthread_once with a futex, based on the code from
__cxa_guard_acquire. For both glibc and musl, the Linux implementation
of pthread_once is already based on futexes, and pthread_once_t is just
a typedef for int, so this change does not alter the layout of
std::once_flag. By choosing the values for the int appropriately, the
new code is even ABI compatible. Code that calls the old implementation
of std::call_once will use pthread_once to manipulate the int, while new
code will use the new std::once_flag members to manipulate it, but they
should interoperate correctly. In both cases, the int is initially zero,
has the lowest bit set when there is an active execution, and equals 2
after a successful returning execution. The difference with the new code
is that exceptional exceptions are correctly detected and the int is
reset to zero.

The __cxa_guard_acquire code (and musl's pthread_once) use an additional
state to say there are other threads waiting. This allows the futex wake
syscall to be skipped if there is no contention. Glibc doesn't use a
waiter bit, so we have to unconditionally issue the wake in order to be
compatible with code calling the old std::call_once that uses Glibc's
pthread_once. If we know that we're using musl (and musl's pthread_once
doesn't change) it would be possible to set a waiting state and check
for it in std::once_flag::_M_finish(bool), but this patch doesn't do
that.

This doesn't fix the bug for non-linux targets. A similar approach could
be used for targets where we know the definition of pthread_once_t is a
mutex and an integer. We could make once_flag._M_activate() use
pthread_mutex_lock on the mutex member within the pthread_once_t, and
then only set the integer if the execution finishes, and then unlock the
mutex. That would require careful study of each target's pthread_once
implementation and that work is left for a later date.

This also fixes PR 55394 because pthread_once is no longer needed, and
PR 84323 because the fast path is now just an atomic load.

As a consequence of the new implementation that doesn't use
pthread_once, we can also make std::call_once work for targets with no
gthreads support. The code for the single-threaded implementation
follows the same methods as on Linux, but with no need for atomics or
futexes.

libstdc++-v3/ChangeLog:

	PR libstdc++/55394
	PR libstdc++/66146
	PR libstdc++/84323
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Add new symbols.
	* include/std/mutex [!_GLIBCXX_HAS_GTHREADS] (once_flag): Define
	even when gthreads is not supported.
	(once_flag::_M_once) [_GLIBCXX_HAVE_LINUX_FUTEX]: Change type
	from __gthread_once_t to int.
	(once_flag::_M_passive(), once_flag::_M_activate())
	(once_flag::_M_finish(bool), once_flag::_Active_execution):
	Define new members for futex and non-threaded implementation.
	[_GLIBCXX_HAS_GTHREADS] (once_flag::_Prepare_execution): New
	RAII helper type.
	(call_once): Use new members of once_flag.
	* src/c++11/mutex.cc (std::once_flag::_M_activate): Define.
	(std::once_flag::_M_finish): Define.
	* testsuite/30_threads/call_once/39909.cc: Do not require
	gthreads.
	* testsuite/30_threads/call_once/49668.cc: Likewise.
	* testsuite/30_threads/call_once/60497.cc: Likewise.
	* testsuite/30_threads/call_once/call_once1.cc: Likewise.
	* testsuite/30_threads/call_once/dr2442.cc: Likewise.
	* testsuite/30_threads/call_once/once_flag.cc: Add test for
	constexpr constructor.
	* testsuite/30_threads/call_once/66146.cc: New test.
	* testsuite/30_threads/call_once/constexpr.cc: Removed.
	* testsuite/30_threads/once_flag/cons/constexpr.cc: Removed.
2020-11-03 18:44:49 +00:00
Jonathan Yong
08fca4df1d libstdc++: use lt_host_flags for libstdc++.la
For platforms like Mingw and Cygwin, cygwin refuses to generate the
shared library without using -no-undefined.

Attached patch makes sure the right flags are used, since libtool is
already used to link libstdc++.

libstdc++-v3/ChangeLog:

	* src/Makefile.am (libstdc___la_LINK): Add lt_host_flags.
	* src/Makefile.in: Regenerate.
2020-11-03 08:22:53 +00:00
GCC Administrator
88ce3d5fbb Daily bump. 2020-11-02 20:53:00 +00:00
Thomas Rodgers
6bcbcea058 libstdc++: Add c++2a <syncstream>
libstdc++-v3/ChangeLog:
	* doc/doxygen/user.cfg.in (INPUT): Add new header.
	* include/Makefile.am (std_headers): Add new header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include new header.
	* include/std/syncstream: New header.
	* include/std/version: Add __cpp_lib_syncbuf.
	* testsuite/27_io/basic_syncbuf/1.cc: New test.
	* testsuite/27_io/basic_syncbuf/2.cc: Likewise.
	* testsuite/27_io/basic_syncbuf/basic_ops/1.cc:
	Likewise.
	* testsuite/27_io/basic_syncbuf/requirements/types.cc:
	Likewise.
	* testsuite/27_io/basic_syncbuf/sync_ops/1.cc:
	Likewise.
	* testsuite/27_io/basic_syncstream/1.cc: Likewise.
	* testsuite/27_io/basic_syncstream/2.cc: Likewise.
	* testsuite/27_io/basic_syncstream/basic_ops/1.cc:
	Likewise.
	* testsuite/27_io/basic_syncstream/requirements/types.cc:
	Likewise.
2020-11-02 10:41:32 -08:00
Jonathan Wakely
29e4184858 libstdc++: Define type traits for wchar_t even when libc support missing
This meets the requirement that std::is_integral_v<wchar_t> is true,
even when full library support for wchar_t via specializations of
char_traits etc. is not provided. This is done by checking
__WCHAR_TYPE__ to see if the compiler knows about the type, rather than
checking the library's own _GLIBCXX_USE_WCHAR_T autoconf macro.

This assumes that the C++ compiler correctly defines wchar_t as a
distinct type, not a typedef for one of the other integeral types. This
is always true for G++ and should be true for any supported non-GNU
compilers.

Similarly, the std::make_unsigned and std::make_signed traits and the
internal helpers std::__is_integer and std::__is_char are also changed
to depend on the same macro.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_integral<wchar_t>)
	(make_unsigned<wchar_t>, make_signed<wchar_t>): Define based
	on #ifdef __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T.
	* include/bits/cpp_type_traits.h (__is_integer<wchar_t>)
	(__is_char<wchar_t>): Likewise.
2020-11-01 11:39:07 +00:00
François Dumont
de77abee11 libstdc++: Fix gnu-version-namespace buid
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog

	* src/c++17/floating_from_chars.cc (_GLIBCXX_USE_CX11_ABI): Add define.
	(buffering_string): New.
	[!_GLIBCXX_USE_CXX11_ABI](reserve_string): New.
	(from_chars): Adapt.
	* src/c++20/sstream-inst.cc: Limit instantiations to
	_GLIBCXX_USE_CXX11_ABI.
2020-10-31 18:10:10 +01:00
Jonathan Wakely
60d9f25487 libstdc++: Prefer double to long double in std::shuffle_order_engine
The transition algorithm for std::shuffle_order_engine uses long double
to ensure that the value (max() - min() + 1) can be accurately
represented, to avoid bias in the shuffling. However, when the base
engine's range is small enough we can avoid slower long double
arithmetic by using double. For example, long double is unnecessary for
any base engine returning 32-bit values.

This makes std::knuth_b::operator() about 15% faster on x86_64, and
probably even more on targets where long double uses soft-float.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (independent_bit_engine): Fix typo
	in comment.
	(shuffle_order_engine): Fix incorrect description in comment.
	* include/bits/random.tcc (__representable_as_double
	(__p1_representable_as_double): New helper functions.
	(shuffle_order_engine::operator()): Use double for calculation
	if (max() - min() + 1) is representable as double.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
2020-10-31 12:54:03 +00:00
Jonathan Wakely
943cc2a1b7 libstdc++: Use double for unordered container load factors [PR 96958]
My previous commit for this PR changed the types from long double to
double, but didn't change the uses of __builtin_ceill and
__builtin_floorl. It also failed to change the non-inline functions in
src/c++11/hashtable_c++0x.cc. This should fix it properly now.

libstdc++-v3/ChangeLog:

	PR libstdc++/96958
	* include/bits/hashtable_policy.h (_Prime_rehash_policy)
	(_Power2_rehash_policy): Use ceil and floor instead of ceill and
	floorl.
	* src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy): Likewise.
	Use double instead of long double.
2020-10-31 00:52:57 +00:00
Patrick Palka
afb8da7faa libstdc++: Don't initialize from *this inside some views [PR97600]
This works around a subtle issue where instantiating the begin()/end()
member of some views (as part of return type deduction) inadvertently
requires computing the satisfaction value of range<foo_view>.

This is problematic because the constraint range<foo_view> requires the
begin()/end() member to be callable.  But it's not callable until we've
deduced its return type, so evaluation of range<foo_view> yields false
at this point.  And if after both members are instantiated (and their
return types deduced) we evaluate range<foo_view> again, this time it
will yield true since the begin()/end() members are now both callable.
This makes the program ill-formed according to [temp.constr.atomic]/3:

  If, at different points in the program, the satisfaction result is
  different for identical atomic constraints and template arguments, the
  program is ill-formed, no diagnostic required.

The views affected by this issue are those whose begin()/end() member
has a placeholder return type and that member initializes an _Iterator
or _Sentinel object from a reference to *this.  The second condition is
relevant because it means explicit conversion functions are considered
during overload resolution (as per [over.match.copy], I think), and
therefore it causes g++ to check the constraints of the conversion
function view_interface<foo_view>::operator bool().  And this conversion
function's constraints indirectly require range<foo_view>.

This issue is observable on trunk only with basic_istream_view (as in
the testcase in the PR).  But a pending patch that makes g++ memoize
constraint satisfaction values indefinitely (it currently invalidates
the satisfaction cache on various events) causes many existing tests for
the other affected views to fail, because range<foo_view> then remains
false for the whole compilation.

This patch works around this issue by adjusting the constructors of the
_Iterator and _Sentinel types of the affected views to take their
foo_view argument by pointer instead of by reference, so that g++ no
longer considers explicit conversion functions when resolving the
direct-initialization inside these views' begin()/end() members.

libstdc++-v3/ChangeLog:

	PR libstdc++/97600
	* include/std/ranges (basic_istream_view::begin): Initialize
	_Iterator from 'this' instead of '*this'.
	(basic_istream_view::_Iterator::_Iterator): Adjust constructor
	accordingly.
	(filter_view::_Iterator::_Iterator): Take a filter_view*
	argument instead of a filter_view& argument.
	(filter_view::_Sentinel::_Sentinel): Likewise.
	(filter_view::begin): Initialize _Iterator from 'this' instead
	of '*this'.
	(filter_view::end): Likewise.
	(transform_view::_Iterator::_Iterator): Take a _Parent* instead
	of a _Parent&.
	(filter_view::_Iterator::operator+): Adjust accordingly.
	(filter_view::_Iterator::operator-): Likewise.
	(filter_view::begin): Initialize _Iterator from 'this' instead
	of '*this'.
	(filter_view::end): Likewise.
	(join_view::_Iterator): Take a _Parent* instead of a _Parent&.
	(join_view::_Sentinel): Likewise.
	(join_view::begin): Initialize _Iterator from 'this' instead of
	'*this'.
	(join_view::end): Initialize _Sentinel from 'this' instead of
	'*this'.
	(split_view::_OuterIter): Take a _Parent& instead of a _Parent*.
	(split_view::begin): Initialize _OuterIter from 'this' instead
	of '*this'.
	(split_view::end): Likewise.
	* testsuite/std/ranges/97600.cc: New test.
2020-10-30 20:33:19 -04:00
Jonathan Wakely
39bf4f14fc libstdc++: Implement P2017R1 "Conditionally borrowed ranges"
This makes some range adaptors model the borrowed_range concept if they
are adapting a borrowed range. This hasn't been added to the C++23
working paper yet, but it has been approved by LWG, and the
recommendation is to treat it as a defect report for C++20 as well.

libstdc++-v3/ChangeLog:

	* include/std/ranges (enable_borrowed_view<take_view<T>>)
	(enable_borrowed_view<drop_view<T>>)
	(enable_borrowed_view<drop_while_view<T>>)
	(enable_borrowed_view<reverse_view<T>>)
	(enable_borrowed_view<common_view<T>>)
	(enable_borrowed_view<elements_view<T>>): Add partial
	specializations as per P2017R1.
	* testsuite/std/ranges/adaptors/conditionally_borrowed.cc:
	New test.
2020-10-30 23:25:52 +00:00
Jonathan Wakely
a1343e5c74 libstdc++: Use double for unordered container load factors [PR 96958]
These calculations were changed to use long double nearly ten years ago
in order to get more precision than float:
https://gcc.gnu.org/pipermail/libstdc++/2011-September/036420.html

However, double should be sufficient, whlie being potentially faster
than long double, and not requiring soft FP calculations for targets
without native long double support.

libstdc++-v3/ChangeLog:

	PR libstdc++/96958
	* include/bits/hashtable_policy.h (_Prime_rehash_policy)
	(_Power2_rehash_policy): Use double instead of long double.
2020-10-30 20:58:08 +00:00
Jonathan Wakely
d1e5d82af8 libstdc++: Fix some more warnings in test
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
	Avoid -Wcatch-value warnings.
2020-10-30 20:58:08 +00:00
Patrick Palka
f3ced6772e libstdc++: Fix the default constructor of ranges::__detail::__box
The class template semiregular-box<T> of [range.semi.wrap] is specified
to value-initialize the underlying object whenever its type is default
initializable.  Our primary template for __detail::__box respects this
requirement, but the recently added partial specialization (for types
that are already semiregular) does not.

This patch fixes this issue, and additionally makes the corresponding in
place constructor explicit (as in the primary template).

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__box): For the partial
	specialization used by types that are already semiregular,
	make the default constructor value-initialize the underlying
	object instead of default-initializing it.  Make its in place
	constructor explicit.
	* testsuite/std/ranges/adaptors/detail/semiregular_box.cc:
	Augment test.
2020-10-30 12:33:13 -04:00
David Edelsohn
dec1eb4c27 libstdc++: AIX xfail for_overwrite.cc testcase
The 20_util/unique_ptr/creation/for_overwrite.cc testcase relies on
operator new, which requires special features on AIX.  This patch
disables the testcase.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: XFAIL on AIX.
2020-10-29 21:57:24 -04:00
GCC Administrator
4f0606fe4b Daily bump. 2020-10-30 00:16:29 +00:00
Jonathan Wakely
ffe6b41015 libstdc++: Fix linker script to remove conflicting patterns
This should fix a bootstrap error on Solaris, due to some of the new
symbols matching old patterns as well as new ones.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten patterns
	for old <sstream> symbols some more.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
a55cda891d libstdc++: Avoid narrowing conversion in subrange constructor
libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange::subrange(R&&)): Use
	direct-initialization instead of list-initialization, so a
	potential narrowing conversion from ranges::size(r) to the
	stored size isn't ill-formed.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
d7aa21a3c7 libstdc++: Fix some warnings in headers
These are usually suppressed in system headers, but should be fixed
anyway.

libstdc++-v3/ChangeLog:

	* include/bits/parse_numbers.h (_Select_int_base): Avoid
	narrowing conversion in constant expression.
	* include/experimental/buffer (buffer_copy): Avoid narrowing
	conversion.
	* include/experimental/internet (hash<>::operator()): Do not
	use deprecated 'argument_type' member.
	* include/std/variant (variant::emplace): Use cast instead
	of implicit conversion from size_t to narrower unsigned type.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
52ddf0d458 libstdc++: Prevent deprecation warnings from <tr1/shared_ptr>
libstdc++-v3/ChangeLog:

	* include/tr1/shared_ptr.h (__shared_count, __shared_ptr)
	(shared_ptr): Add diagnostic pragmas around uses of auto_ptr.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Adust dg-error line numbers.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
13feb0234b libstdc++: Avoid warnings in tests
This fixes some warnings emitted when testing with warning flags added.
Some of these are only necessary when testing with -Wsystem-headers, but
either way it cleans up the tests to be less noisy under non-default
flags.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Avoid -Wunused warnings.
	* testsuite/20_util/any/assign/2.cc: Likewise.
	* testsuite/20_util/any/cons/2.cc: Likewise.
	* testsuite/20_util/align/1.cc: Avoid -Wsign-compare warning.
	* testsuite/20_util/function/65760.cc: Avoid -Wunused warning.
	* testsuite/20_util/function/1.cc: Avoid -Wcatch-value warning.
	* testsuite/20_util/function/cons/move_target.cc: Avoid -Wunused
	warning.
	* testsuite/20_util/headers/memory/synopsis.cc: Add exception
	specification.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Avoid
	-Wsign-compare warning.
	* testsuite/20_util/tuple/cons/deduction.cc: Avoid -Wunused
	warning.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc:
	Avoid -Wdeprecated-copy warning.
	* testsuite/21_strings/basic_string/56166.cc: Avoid
	-Wcatch-value warning.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
	Avoid -Wcatch-value warnings.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc:
	Prune additional diagnostics.
	* testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/headers/string/synopsis.cc: Add exception
	specifications.
	* testsuite/22_locale/locale/cons/12352.cc: Define sized
	delete operators to avoid warnings.
	* testsuite/23_containers/deque/modifiers/swap/1.cc: Add
	exception specification.
	* testsuite/23_containers/forward_list/cons/11.cc: Avoid
	-Wdeprecated-copy warning.
	* testsuite/23_containers/headers/bitset/synopsis.cc: Add
	exception specification.
	* testsuite/23_containers/headers/deque/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/forward_list/synopsis.cc:
	Likewise.
	* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/map/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/queue/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/set/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/vector/synopsis.cc: Likewise.
	* testsuite/23_containers/list/modifiers/swap/1.cc: Likewise.
	* testsuite/23_containers/map/modifiers/swap/1.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/swap/1.cc:
	Likewise.
	* testsuite/23_containers/multiset/modifiers/swap/1.cc:
	Likewise.
	* testsuite/23_containers/set/modifiers/swap/1.cc: Likewise.
	* testsuite/23_containers/unordered_set/56267-2.cc: Avoid
	-Wdeprecated-copy warning.
	* testsuite/23_containers/vector/bool/23632.cc: Avoid
	-Wempty-body warning.
	* testsuite/23_containers/vector/modifiers/swap/1.cc: Add
	exception specification.
	* testsuite/25_algorithms/heap/moveable2.cc: Fix misplaced
	parentheses around arguments.
	* testsuite/25_algorithms/sample/1.cc: Use return value.
	* testsuite/25_algorithms/search/searcher.cc: Avoid -Wunused
	warnings.
	* testsuite/27_io/basic_ostream/exceptions/char/9561.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Avoid
	-Wsign-compare warning.
	* testsuite/experimental/any/assign/2.cc: Avoid -Wunused warnings.
	* testsuite/experimental/any/cons/2.cc: Likewise.
	* testsuite/experimental/filesystem/operations/remove_all.cc:
	Avoid -Wign-compare warning.
	* testsuite/experimental/memory/observer_ptr/cons/cons.cc:
	Likewise.
	* testsuite/experimental/memory_resource/null_memory_resource.cc:
	Likewise.
	* testsuite/experimental/source_location/1.cc: Avoid -Waddress
	warning.
	* testsuite/ext/pod_char_traits.cc: Avoid -Wunused warning.
	* testsuite/ext/vstring/modifiers/clear/56166.cc: Avoid
	-Wcatch-value.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
	Avoid -Wunused warning.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Prune additional warnings.
	* testsuite/tr1/3_function_objects/function/1.cc: Avoid
	-Wcatch-value warning.
	* testsuite/util/replacement_memory_operators.h: Define sized
	delete to avoid warnings.
	* testsuite/util/testsuite_api.h (_NonDefaultConstructible): Add
	user-declared assignment operator to stop -Wdeprecated-copy
	warnings.
	* testsuite/util/testsuite_containers.h: Avoid -Wunused warning.
	* testsuite/util/testsuite_iterators.h: Avoid -Wsign-compare
	warnings.
	* testsuite/util/testsuite_new_operators.h: Define sized deleted.
2020-10-29 22:47:21 +00:00
Jonathan Wakely
8c84486bba libstdc++: Improve tests for constexpr algorithms
These tests just return true without checking that the results of the
algorithms. Although it should be safe to assume that the algorithms
behave the same at compile-time as at run-time, we can use these tests
to verify it.

This replaces each 'return true' statement with a condition that depends
on the basic functionality of the algorithm, such as returning an
iterator to the right position.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/all_of/constexpr.cc: Check result of
	the algorithm.
	* testsuite/25_algorithms/any_of/constexpr.cc: Likewise.
	* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
	* testsuite/25_algorithms/copy_backward/constexpr.cc: Likewise.
	* testsuite/25_algorithms/count/constexpr.cc: Likewise.
	* testsuite/25_algorithms/equal/constexpr.cc: Likewise.
	* testsuite/25_algorithms/equal_range/constexpr.cc: Likewise.
	* testsuite/25_algorithms/fill/constexpr.cc: Likewise.
	* testsuite/25_algorithms/find_end/constexpr.cc: Likewise.
	* testsuite/25_algorithms/find_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_partitioned/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_permutation/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/constexpr.cc: Likewise.
	* testsuite/25_algorithms/merge/constexpr.cc: Likewise.
	* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
	* testsuite/25_algorithms/none_of/constexpr.cc: Likewise.
	* testsuite/25_algorithms/partition_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/remove_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/remove_copy_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/remove_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/replace_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/reverse/constexpr.cc: Likewise.
	* testsuite/25_algorithms/reverse_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/rotate_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/search/constexpr.cc: Likewise.
	* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
	* testsuite/25_algorithms/set_intersection/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
	* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.
2020-10-29 14:47:18 +00:00
Jonathan Wakely
822c1d21a3 libstdc++: Allow Lemire's algorithm to be used in more cases
This extends the fast path to also work when the URBG's range of
possible values is not the entire range of its result_type. Previously,
the slow path would be used for engines with a uint_fast32_t result type
if that type is actually a typedef for uint64_t rather than uint32_t.
After this change, the generator's result_type is not important, only
the range of possible value that generator can produce. If the
generator's range is exactly UINT64_MAX then the calculation will be
done using 128-bit and 64-bit integers, and if the range is UINT32_MAX
it will be done using 64-bit and 32-bit integers.

In practice, this benefits most of the engines and engine adaptors
defined in [rand.predef] on x86_64-linux and other 64-bit targets. This
is because std::minstd_rand0 and std::mt19937 and others use
uint_fast32_t, which is a typedef for uint64_t.

The code now makes use of the recently-clarified requirement that the
generator's min() and max() functions are usable in constant
expressions (see LWG 2154).

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (_Power_of_two): Add
	constexpr.
	(uniform_int_distribution::_S_nd): Add static_assert to ensure
	the wider type is twice as wide as the result type.
	(uniform_int_distribution::__generate_impl): Add static_assert
	and declare variables as constexpr where appropriate.
	(uniform_int_distribution:operator()): Likewise. Only consider
	the uniform random bit generator's range of possible results
	when deciding whether _S_nd can be used, not the __uctype type.
2020-10-29 14:47:18 +00:00
Jonathan Wakely
d067bd7293 libstdc++: Do not use volatile for __gnu_cxx::rope reference counting
The rope extension uses a volatile variable for its reference count.
This is not only unnecessary for correctness (volatile provides neither
atomicity nor memory visibility, and the variable is only modified while
a lock is held) but it now causes deprecated warnings with
-Wsystem-headers due to the use of ++ and -- operators.

It would be possible to use __gnu_cxx::__exchange_and_add in _M_incr and
_M_decr when __atomic_is_lock_free(sizeof(_RC_t), &_M_ref_count) is
true, rather than locking a mutex. That would probably be a significant
improvement for multi-threaded and single-threaded code (because
__exchange_and_add will use non-atomic ops when possible, and even in MT
code it should be faster than the mutex lock/unlock pair). However,
mixing objects compiled with the old and new code would result in
inconsistent synchronization being used for the reference count.

libstdc++-v3/ChangeLog:

	* include/ext/rope (_Refcount_Base::_M_ref_count): Remove
	volatile qualifier.
	(_Refcount_Base::_M_decr()): Likewise.
2020-10-29 14:47:17 +00:00
Jonathan Wakely
3c9b99ef71 libstdc++: Make std::function work better with -fno-rtti
This change allows std::function::target<F>() to work even without RTTI,
using the same approach as std::any. Because we know what the manager
function would be for a given type, we can check if the stored pointer
has the expected address. If it does, we don't need to use RTTI. If it
isn't equal, we still need to do the RTTI check (when RTTI is enabled)
to handle the case where the same function has different addresses in
different shared objects.

This also changes the implementation of the manager function to return a
null pointer result when asked for the type_info of the target object.
This not only avoids a warning with -Wswitch -Wsystem-headers, but also
avoids prevents std::function::target_type() from dereferencing an
uninitialized pointer when the linker keeps an instantiation of the
manager function that was compiled without RTTI.

Finally, this fixes a bug in the non-const overload of function::target
where calling it with a function type F was ill-formed, due to
attempting to use const_cast<F*>(ptr). The standard only allows
const_cast<T*> when T is an object type.  The solution is to use
*const_cast<F**>(&ptr) instead, because F* is an object type even if F
isn't. I've also used _GLIBCXX17_CONSTEXPR in function::target so that
it doesn't bother instantiating anything for types that can never be a
valid target.

libstdc++-v3/ChangeLog:

	* include/bits/std_function.h (_Function_handler<void, void>):
	Define explicit specialization used for invalid target types.
	(_Base_manager::_M_manager) [!__cpp_rtti]: Return null.
	(function::target_type()): Check for null pointer.
	(function::target()): Define unconditionall. Fix bug with
	const_cast of function pointer type.
	(function::target() const): Define unconditionally, but
	only use RTTI if enabled.
	* testsuite/20_util/function/target_no_rtti.cc: New test.
2020-10-29 14:47:17 +00:00
Patrick Palka
2e0216f9c4 libstdc++: Fix memory issue in ranges::lexicographical_compare testcase
libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
	(test03): Fix initializing the vector vy with the array y of size 4.
2020-10-29 10:11:12 -04:00
Patrick Palka
64817472be libstdc++: Correct PR number in ChangeLog entry 2020-10-29 09:28:43 -04:00
Jonathan Wakely
eb6b71b83c libstdc++: Fix some warnings in headers
These are usually suppressed without -Wsystem-headers.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Local_iterator_base): Cast
	value to avoid -Wsign-compare warnings.
	* include/bits/regex.h (sub_match::_M_str): Avoid narrowing
	conversion.
	* include/bits/regex_compiler.tcc (_Compiler::_M_quantifier):
	Initialize variable to avoid -Wmaybe-uninitialized warning.
	* include/bits/shared_ptr_base.h (_Sp_counted_deleter::_Impl):
	Reorder mem-initializer-list to avoid -Wreorder warning.
	* include/bits/stl_tree.h (_Rb_tree_impl): Explicitly
	initialize base class in copy constructor.
	* include/debug/safe_iterator.h (_Safe_iterator): Likewise.
	* include/ext/debug_allocator.h: Reorder mem-initializer-list
	to avoid -Wreorder warning.
	* include/ext/throw_allocator.h (throw_allocator_limit)
	(throw_allocator_random): Add user-declared assignment operators
	to avoid -Wdeprecated-copy warnings.
2020-10-29 11:43:55 +00:00
Jonathan Wakely
68990ed13d libstdc++: Rename _UniformRandomNumberGenerator parameters
The paper P0346R1 renamed uniform random number generators to
uniform random bit generators, to describe their purpose more
accurately. This makes that same change in one of the relevant
files (but not the others).

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (uniform_int_distribution):
	Rename _UniformRandomNumberGenerator template parameters to
	_UniformRandomBitGenerator, as per P0346R1.
2020-10-29 09:09:44 +00:00
Jonathan Wakely
c6bfc4eb3c libstdc++: Fix new basic_stringbuf constructor
libstdc++-v3/ChangeLog:

	* include/std/sstream (basic_stringbuf(__string_type&&, openmode)):
	Call _M_init_syncbuf to set up get/put areas. Also qualify
	std::move.
2020-10-29 01:28:12 +00:00