Commit Graph

11794 Commits

Author SHA1 Message Date
Ville Voutilainen
02cbd79e47 libstdc++: Fix variant build on 32-bit targets [PR95904]
libstdc++-v3/ChangeLog:

	* include/std/variant (__check_visitor_result):
	Use size_t for indexes.
	(__check_visitor_results): Likewise.
2020-10-10 14:03:00 +03:00
GCC Administrator
c74a0e82fa Daily bump. 2020-10-10 00:16:26 +00:00
Ville Voutilainen
3427e31331 libstdc++: Diagnose visitors with different return types [PR95904]
libstdc++-v3/ChangeLog:

	PR libstdc++/95904
	* include/std/variant (__deduce_visit_result): Add a nested ::type.
	(__gen_vtable_impl</*base case*/>::_S_apply):
	Check the visitor return type.
	(__same_types): New.
	(__check_visitor_result): Likewise.
	(__check_visitor_results): Likewise.
	(visit(_Visitor&&, _Variants&&...)): Use __check_visitor_results
	in case we're visiting just one variant.
	* testsuite/20_util/variant/visit_neg.cc: Adjust.
2020-10-09 20:48:08 +03:00
Jonathan Wakely
3ee44d4c51 libstdc++: Fix incorrect results in std::seed_seq::generate [PR 97311]
This ensures that intermediate results are done in uint32_t values,
meeting the requirement for operations to be done modulo 2^32.

If the target doesn't define __UINT32_TYPE__ then substitute uint32_t
with a class type that uses uint_least32_t and masks the value to
UINT32_MAX.

I've also split the first loop that goes from k=0 to k<m into three
loops, for k=0, [1,s] and [s+1,m). This avoids branching for those three
cases in the body of the loop, and also avoids the concerns in PR 94823
regarding the k-1 index when k==0.

libstdc++-v3/ChangeLog:

	PR libstdc++/97311
	* include/bits/random.tcc (seed_seq::generate): Use uint32_t for
	calculations. Also split the first loop into three loops to
	avoid branching on k on every iteration, resolving PR 94823.
	* testsuite/26_numerics/random/seed_seq/97311.cc: New test.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-erro
	line number.
2020-10-09 16:58:32 +01:00
Daniel Lemire
98c37d3bac libstdc++: Optimize uniform_int_distribution using Lemire's algorithm
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (uniform_int_distribution::_S_nd):
	New member function implementing Lemire's "nearly divisionless"
	algorithm.
	(uniform_int_distribution::operator()): Use _S_nd when the range
	of the URBG is the full width of the result type.
2020-10-09 14:09:36 +01:00
Jonathan Wakely
6ce2cb116a libstdc++: Adjust variable export in makefile
We usually export variables in recipes this way. I'm not sure it's
necessary, but it's consistent.

libstdc++-v3/ChangeLog:

	* testsuite/Makefile.am: Set and export variable separately.
	* testsuite/Makefile.in: Regenerate.
2020-10-09 14:08:42 +01:00
Jonathan Wakely
7e7eef2a1b libstdc++: Pass CXXFLAGS to check_performance script
It looks like our check-performance target runs completely unoptimized,
which is a bit silly. This exports the CXXFLAGS from the parent make
process to the check_performance script.

libstdc++-v3/ChangeLog:

	* scripts/check_performance: Use gnu++11 instead of gnu++0x.
	* testsuite/Makefile.am (check-performance): Export CXXFLAGS to
	child process.
	* testsuite/Makefile.in: Regenerate.
2020-10-09 14:01:55 +01:00
Jonathan Wakely
f9919ba717 libstdc++: Add performance test for <random>
This tests std::uniform_int_distribution with various parameters and
engines.

libstdc++-v3/ChangeLog:

	* testsuite/performance/26_numerics/random_dist.cc: New test.
2020-10-09 14:01:54 +01:00
Jonathan Wakely
afcbeb35e0 libstdc++: Fix unused variable warning
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_performance.h (report_header): Remove
	unused variable.
2020-10-09 11:53:08 +01:00
GCC Administrator
da9df69975 Daily bump. 2020-10-09 00:16:27 +00:00
Patrick Palka
9158a4d2a6 libstdc++: Make ranges::construct_at constexpr-friendly [PR95788]
This rewrites ranges::construct_at in terms of std::construct_at so
that we can piggyback on the compiler's existing support for
intercepting placement new within std::construct_at during constexpr
evaluation, instead of having to additionally teach the compiler about
ranges::construct_at.

While we're making changes to ranges::construct_at, this patch also
declares it conditionally noexcept and qualifies the calls to declval in
its requires-clause.

libstdc++-v3/ChangeLog:

	PR libstdc++/95788
	* include/bits/ranges_uninitialized.h:
	(__construct_at_fn::operator()): Rewrite in terms of
	std::construct_at.  Declare it conditionally noexcept.  Qualify
	calls to declval in its requires-clause.
	* testsuite/20_util/specialized_algorithms/construct_at/95788.cc:
	New test.
2020-10-08 18:10:05 -04:00
Jonathan Wakely
b2a96bf9dc libstdc++: Add assertions for preconditions in sampling distributions [PR 82584]
These three distributions all require 0 < S where S is the sum of the
weights. When the sum is zero there's an undefined FP division by zero.
Add assertions to help users diagnose the problem.

libstdc++-v3/ChangeLog:

	PR libstdc++/82584
	* include/bits/random.tcc
	(discrete_distribution::param_type::_M_initialize)
	(piecewise_constant_distribution::param_type::_M_initialize)
	(piecewise_linear_distribution::param_type::_M_initialize):
	Add assertions for positive sums..
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line.
2020-10-08 15:24:21 +01:00
Jonathan Wakely
f997b67550 libstdc++: Add C++11 member functions for ios::failure in old ABI
The new constructors that C++11 added to std::ios_base::failure were
missing for the old ABI. This adds them, but just ignores the
std::error_code argument (because there's nowhere to store it).

This also adds a code() member, which should be provided by the
std::system_error base class, but that base class isn't present in the
old ABI.

This allows the old ios::failure to be used in code that expects the new
API, although with reduced functionality.

libstdc++-v3/ChangeLog:

	* include/bits/ios_base.h (ios_base::failure): Add constructors
	takeing error_code argument. Add code() member function.
	* testsuite/27_io/ios_base/failure/cxx11.cc: Allow test to
	run for the old ABI but do not check for derivation from
	std::system_error.
	* testsuite/27_io/ios_base/failure/error_code.cc: New test.
2020-10-08 14:45:37 +01:00
Jonathan Wakely
c06617a79b libstdc++: Avoid divide by zero in default template arguments
My previous attempt to fix this only worked when m is a power of two.
There is still a bug when a=00 and !has_single_bit(m).

Instead of trying to make _Mod work for a==0 this change ensures that we
never instantiate it with a==0. For C++17 we can use if-constexpr, but
otherwise we need to use a different multipler. It doesn't matter what
we use, as it won't actually be called, only instantiated.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (__detail::_Mod): Revert last change.
	(__detail::__mod): Do not use _Mod for a==0 case.
	* testsuite/26_numerics/random/linear_congruential_engine/operators/call.cc:
	Check other cases with a==0. Also check runtime results.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line.
2020-10-08 14:45:36 +01:00
GCC Administrator
6caec77e3b Daily bump. 2020-10-08 00:16:30 +00:00
Jonathan Wakely
6ae17a3b68 libstdc++: Fix divide by zero in default template argument
libstdc++-v3/ChangeLog:

	* include/bits/random.h (__detail::_Mod): Avoid divide by zero.
	* testsuite/26_numerics/random/linear_congruential_engine/operators/call.cc:
	New test.
2020-10-08 00:34:56 +01:00
Jonathan Wakely
23f75da95f libstdc++: Fix non-reserved names in headers
My recent changes to std::exception_ptr moved some members to be inline
in the header but didn't replace the variable names with reserved names.

The "tmp" variable must be fixed. The "other" parameter is actually a
reserved name because of std::allocator<T>::rebind<U>::other but should
be fixed anyway.

There are also some bad uses of "ForwardIterator" in <ranges>.

There's also a "il" parameter in a std::seed_seq constructor in <random>
which is only reserved since C++14.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (seed_seq(initializer_list<T>)): Rename
	parameter to use reserved name.
	* include/bits/ranges_algo.h (shift_left, shift_right): Rename
	template parameters to use reserved name.
	* libsupc++/exception_ptr.h (exception_ptr): Likewise for
	parameters and local variables.
	* testsuite/17_intro/names.cc: Check "il". Do not check "d" and
	"y" in C++20 mode.
2020-10-08 00:05:53 +01:00
GCC Administrator
8e97b9052d Daily bump. 2020-10-07 00:16:35 +00:00
Jonathan Wakely
1352ea1925 libstdc++: Inline std::exception_ptr members [PR 90295]
This inlines most members of std::exception_ptr so that all operations
on a null exception_ptr can be optimized away. This benefits code like
std::future and coroutines where an exception_ptr object is present to
cope with exceptional cases, but is usually not used and remains null.

Since those functions were previously non-inline we have to continue to
export them from the library, for objects that were compiled against the
old headers and expect to find definitions in the library.

In order to inline the copy constructor and destructor we need to export
the _M_addref() and _M_release() members that increment/decrement the
reference count when copying/destroying a non-null exception_ptr. The
copy ctor and dtor check for null and don't call _M_addref and
_M_release unless they need to. The checks for null pointers in
_M_addref and _M_release are still needed because old code might call
them without checking for null first. But we can use __builtin_expect to
predict that they are usually called for the non-null case.

libstdc++-v3/ChangeLog:

	PR libstdc++/90295
	* config/abi/pre/gnu.ver (CXXABI_1.3.13): New symbol version.
	(exception_ptr::_M_addref(), exception_ptr::_M_release()):
	Export symbols.
	* libsupc++/eh_ptr.cc (exception_ptr::exception_ptr()):
	Remove out-of-line definition.
	(exception_ptr::exception_ptr(const exception_ptr&)):
	Likewise.
	(exception_ptr::~exception_ptr()): Likewise.
	(exception_ptr::operator=(const exception_ptr&)):
	Likewise.
	(exception_ptr::swap(exception_ptr&)): Likewise.
	(exception_ptr::_M_addref()): Add branch prediction.
	* libsupc++/exception_ptr.h (exception_ptr::operator bool):
	Add noexcept.
	[!_GLIBCXX_EH_PTR_COMPAT] (operator==, operator!=): Define
	inline as hidden friends. Remove declarations at namespace
	scope.
	(exception_ptr::exception_ptr()): Define inline.
	(exception_ptr::exception_ptr(const exception_ptr&)):
	Likewise.
	(exception_ptr::~exception_ptr()): Likewise.
	(exception_ptr::operator=(const exception_ptr&)):
	Likewise.
	(exception_ptr::swap(exception_ptr&)): Likewise.
	* testsuite/util/testsuite_abi.cc: Add CXXABI_1.3.13.
	* testsuite/18_support/exception_ptr/90295.cc: New test.
2020-10-06 17:24:16 +01:00
Jonathan Wakely
9065c4adab libstdc++: Avoid CTAD for std::ranges::join_view [LWG 3474]
In commit ef275d1f20 I implemented the
wrong resolution of LWG 3474. This removes the deduction guide and
alters the views::join factory to create the right type explicitly.

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view): Remove deduction guide.
	(views::join): Add explicit template argument list to prevent
	deducing the wrong type.
	* testsuite/std/ranges/adaptors/join.cc: Move test for LWG 3474
	here, from ...
	* testsuite/std/ranges/adaptors/join_lwg3474.cc: Removed.
2020-10-06 09:41:40 +01:00
GCC Administrator
7e9282ae62 Daily bump. 2020-10-06 00:16:25 +00:00
Jonathan Wakely
9af65c2b90 libstdc++: Reduce uses of std::numeric_limits
This avoids unnecessary instantiations of std::numeric_limits or
inclusion of <limits> when a more lightweight alternative would work.
Some uses can be replaced with __gnu_cxx::__int_traits and some can just
use size_t(-1) directly where SIZE_MAX is needed.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h: Use __int_traits<int> instead of
	std::numeric_limits<int>.
	* include/bits/uniform_int_dist.h: Use __int_traits<T>::__max
	instead of std::numeric_limits<T>::max().
	* include/bits/hashtable_policy.h: Use size_t(-1) instead of
	std::numeric_limits<size_t>::max().
	* include/std/regex: Include <ext/numeric_traits.h>.
	* include/std/string_view: Use typedef for __int_traits<int>.
	* src/c++11/hashtable_c++0x.cc: Use size_t(-1) instead of
	std::numeric_limits<size_t>::max().
	* testsuite/std/ranges/iota/96042.cc: Include <limits>.
	* testsuite/std/ranges/iota/difference_type.cc: Likewise.
	* testsuite/std/ranges/subrange/96042.cc: Likewise.
2020-10-06 00:05:11 +01:00
Jonathan Wakely
1c72f460e9 libstdc++: Minor header cleanup in <numeric>
When adding new features to <numeric> I included the required headers
adjacent to the new code. This cleans it up by moving all the includes
to the start of the file.

libstdc++-v3/ChangeLog:

	* include/std/numeric: Move all #include directives to the top
	of the header.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line
	numbers.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
2020-10-05 22:46:46 +01:00
Jonathan Wakely
f92a504fdd libstdc++: Make allocators throw bad_array_new_length on overflow [LWG 3190]
std::allocator and std::pmr::polymorphic_allocator should throw
std::bad_array_new_length from their allocate member functions if the
number of bytes required cannot be represented in std::size_t.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver: Add new symbol.
	* include/bits/functexcept.h (__throw_bad_array_new_length):
	Declare new function.
	* include/ext/malloc_allocator.h (malloc_allocator::allocate):
	Throw bad_array_new_length for impossible sizes (LWG 3190).
	* include/ext/new_allocator.h (new_allocator::allocate):
	Likewise.
	* include/std/memory_resource (polymorphic_allocator::allocate)
	(polymorphic_allocator::allocate_object): Use new function,
	__throw_bad_array_new_length.
	* src/c++11/functexcept.cc (__throw_bad_array_new_length):
	Define.
	* testsuite/20_util/allocator/lwg3190.cc: New test.
2020-10-05 15:18:56 +01:00
Mike Crowe
f33a43f9f7 libstdc++: Use correct duration for atomic_futex wait on custom clock [PR 91486]
As Jonathan Wakely pointed out[1], my change in commit
f9ddb696a2 should have been rounding to
the target clock duration type rather than the input clock duration type
in __atomic_futex_unsigned::_M_load_when_equal_until just as (e.g.)
condition_variable does.

As well as fixing this, let's create a rather contrived test that fails
with the previous code, but unfortunately only when run on a machine
with an uptime of over 208.5 days, and even then not always.

[1] https://gcc.gnu.org/pipermail/libstdc++/2020-September/051004.html

libstdc++-v3/ChangeLog:

	PR libstdc++/91486
	* include/bits/atomic_futex.h:
	(__atomic_futex_unsigned::_M_load_when_equal_until): Use target
	clock duration type when rounding.
	* testsuite/30_threads/async/async.cc (test_pr91486_wait_for):
	Rename from test_pr91486.
	(float_steady_clock): New class for test.
	(test_pr91486_wait_until): New test.
2020-10-05 11:32:10 +01:00
Mike Crowe
d5243c4626 libstdc++: Test C++11 implementation of std::chrono::__detail::ceil
Commit 53ad6b1979 split the implementation
of std::chrono::__detail::ceil so that when compiling for C++17 and
later std::chrono::ceil is used but when compiling for earlier versions
a separate implementation is used to comply with C++11's limited
constexpr rules. Let's run the equivalent of the existing
std::chrono::ceil test cases on std::chrono::__detail::ceil too to make
sure that it doesn't get broken.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/duration_cast/rounding_c++11.cc: Copy
	rounding.cc and alter to support compilation for C++11 and to
	test std::chrono::__detail::ceil.
2020-10-05 11:09:03 +01:00
Jonathan Wakely
b98d3cc566 libstdc++: Add missing bugzilla PR numbers to ChangeLog
We missed these out of the git commit messages.
2020-10-05 10:46:25 +01:00
GCC Administrator
b0b9b8f02a Daily bump. 2020-10-03 00:16:25 +00:00
Jonathan Wakely
324118378e libstdc++: Change test to work without 64-bit atomics
This fixes a linker error for older ARM cores without 64-bit atomics.

I think the { dg-add-options libatomic } is no longer needed, but it's
harmless to keep it there.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic_float/value_init.cc: Use float
	instead of double so that __atomic_load_8 isn't needed.
2020-10-02 22:18:51 +01:00
Jonathan Wakely
1ad08b64ce libstdc++: Fix testcase by using terminate handler
This test was supposed to verify that when __libc_single_threaded is
available we successfully detect recursive static initialization even
when linked to libpthread. But I forgot to that when recursive init is
detected, we terminate, and so the test fails.

This adds a terminate handler that exits cleanly, so the test passes
when recursive init is detected.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Use terminate handler that
	calls _Exit(0).
2020-10-02 22:18:51 +01:00
Patrick Palka
080a23bce1 libstdc++: Add missing P0896 changes to <iterator>
I noticed that the following changes from this paper were not yet
implemented.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (reverse_iterator::iter_move):
	Define for C++20 as per P0896.
	(reverse_iterator::iter_swap): Likewise.
	(move_iterator::operator*): Apply P0896 changes for C++20.
	(move_iterator::operator[]): Likewise.
	* testsuite/24_iterators/reverse_iterator/cust.cc: New test.
2020-10-02 10:51:31 -04:00
GCC Administrator
6c2675fa2b Daily bump. 2020-10-02 00:16:27 +00:00
Jonathan Wakely
026ca1121c libstdc++: Fix test_and_acquire for EABI
libstdc++-v3/ChangeLog:

	* config/cpu/arm/cxxabi_tweaks.h (_GLIBCXX_GUARD_TEST_AND_ACQUIRE):
	Do not try to dereference return value of __atomic_load_n.
2020-10-01 12:54:37 +01:00
GCC Administrator
660bfe61d4 Daily bump. 2020-10-01 00:16:30 +00:00
Jonathan Wakely
d1ac0f0dfb libstdc++: Fix test_and_acquire / set_and_release for EABI guard variables
The default definitions of _GLIBCXX_GUARD_TEST_AND_ACQUIRE and
_GLIBCXX_GUARD_SET_AND_RELEASE in libsupc++/guard.cc only work for the
generic (IA64) ABI, because they test/set the first byte of the guard
variable. For EABI we need to use the least significant bit, which means
using the first byte is wrong for big endian targets.

This has been wrong since r224411, but previously it only caused poor
performance. The _GLIBCXX_GUARD_TEST_AND_ACQUIRE at the very start of
__cxa_guard_acquire would always return false even if the initialization
was actually complete. Before my r11-3484 change the atomic compare
exchange would have loaded the correct value, and then returned 0 as
expected when the initialization is complete. After my change, in the
single-threaded case there is no redundant check for init being
complete, because I foolishly assumed that the check at the start of the
function actually worked.

The default definition of _GLIBCXX_GUARD_SET_AND_RELEASE is also wrong
for big endian EABI, but appears to work because it sets the wrong bit
but then the buggy TEST_AND_ACQUIRE tests that wrong bit as well. Also,
the buggy SET_AND_RELEASE macro is only used for targets with threads
enabled but no futex syscalls.

This should fix the regressions introduced by my patch, by defining
custom versions of the TEST_AND_ACQUIRE and SET_AND_RELEASE macros that
are correct for EABI.

libstdc++-v3/ChangeLog:

	* config/cpu/arm/cxxabi_tweaks.h (_GLIBCXX_GUARD_TEST_AND_ACQUIRE):
	(_GLIBCXX_GUARD_SET_AND_RELEASE): Define for EABI.
2020-09-30 21:14:43 +01:00
Jonathan Wakely
73ae6eb572 libstdc++: Use __is_same instead of __is_same_as
PR 92271 added __is_same as another spelling of __is_same_as. Since
Clang also spells it __is_same, let's just use that consistently.

It appears that Intel icc sets __GNUC__ to 10, but only supports
__is_same_as. If we only use __is_same for __GNUC__ >= 11 then we won't
break icc again (it looks like we broke previous versions of icc when we
started using __is_same_as).

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME):
	Define for GCC 11 or when !__is_identifier(__is_same).
	(_GLIBCXX_BUILTIN_IS_SAME_AS): Remove.
	* include/std/type_traits (is_same, is_same_v): Replace uses
	of _GLIBCXX_BUILTIN_IS_SAME_AS.
2020-09-30 18:41:12 +01:00
GCC Administrator
e84761c6f3 Daily bump. 2020-09-29 00:16:30 +00:00
Patrick Palka
361e32eeaa libstdc++: Rearrange some range adaptors' data members
Since the standard range adaptors are specified to derive from the empty
class view_base, having their first data member store the underlying
view is suboptimal, for if the underlying view also derives from
view_base then the two view_base subobjects will be adjacent; this
prevents the compiler from applying the empty base optimization to elide
away the storage for these two empty bases.

This patch improves the situation by declaring the _M_base data member
last instead of first in each range adaptor that has more than one data
member, so that the empty base optimization can apply in more cases.

libstdc++-v3/ChangeLog:

	* include/std/ranges (filter_view): Declare the data member
	_M_base last instead of first, and adjust constructors' member
	initializer lists accordingly.
	(transform_view): Likewise.
	(take_view): Likewise.
	(take_while_view): Likewise.
	(drop_view): Likewise.
	(drop_while_view): Likewise.
	(join_view): Likewise.
	(split_view): Likewise (and tweak nearby formatting).
	(reverse_view): Likewise.
	* testsuite/std/ranges/adaptors/sizeof.cc: Update expected
	sizes.
2020-09-28 12:05:32 -04:00
Patrick Palka
ea51fba504 libstdc++: Add test that tracks range adaptors' sizes
libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/adaptors/sizeof.cc: New test.
2020-09-28 11:55:21 -04:00
Patrick Palka
620db4ca60 libstdc++: Reduce the size of a subrange with empty sentinel type
libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange::_M_end): Give it
	[[no_unique_address]].
	* testsuite/std/ranges/subrange/sizeof.cc: New test.
2020-09-28 11:55:04 -04:00
Patrick Palka
623443357e libstdc++: Reduce the size of an unbounded iota_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (iota_view::_M_bound): Give it
	[[no_unique_address]].
	* testsuite/std/ranges/iota/iota_view.cc: Check that an
	unbounded iota_view has minimal size.
2020-09-28 11:54:57 -04:00
GCC Administrator
4383c595ce Daily bump. 2020-09-28 00:16:21 +00:00
Clément Chigot
3c11f25fb8 aix: Use $(AR) without -X32_64 to build FAT libraries.
AIX FAT libraries should be built with the version of AR chosen by configure.
The GNU Make $(AR) variable includes the AIX -X32_64 option needed
by the default Makefile rules to accept both 32 bit and 64 bit object files.
The -X32_64 option conflicts with ar archiving objects of the same name
used to build FAT libraries.

This patch changes the Makefile fragments for AIX FAT libraries to use $(AR),
but strips the -X32_64 option from the Make variable.

libgcc/ChangeLog:

2020-09-27  Clement Chigot  <clement.chigot@atos.net>

	* config/rs6000/t-slibgcc-aix: Use $(AR) without -X32_64.

libatomic/ChangeLog:

2020-09-27  Clement Chigot  <clement.chigot@atos.net>

	* config/t-aix: Use $(AR) without -X32_64.

libgomp/ChangeLog:

2020-09-27  Clement Chigot  <clement.chigot@atos.net>

	* config/t-aix: Use $(AR) without -X32_64.

libstdc++-v3/ChangeLog:

2020-09-27  Clement Chigot  <clement.chigot@atos.net>

	* config/os/aix/t-aix: Use $(AR) without -X32_64.

libgfortran/ChangeLog:

2020-09-27  Clement Chigot  <clement.chigot@atos.net>

	* config/t-aix: Use $(AR) without -X32_64.
2020-09-27 12:43:29 -04:00
GCC Administrator
91dd4a3864 Daily bump. 2020-09-27 00:16:24 +00:00
Jonathan Wakely
e6923541fa libstdc++: Use __libc_single_threaded to optimise atomics [PR 96817]
Glibc 2.32 adds a global variable that says whether the process is
single-threaded. We can use this to decide whether to elide atomic
operations, as a more precise and reliable indicator than
__gthread_active_p.

This means that guard variables for statics and reference counting in
shared_ptr can use less expensive, non-atomic ops even in processes that
are linked to libpthread, as long as no threads have been created yet.
It also means that we switch to using atomics if libpthread gets loaded
later via dlopen (this still isn't supported in general, for other
reasons).

We can't use __libc_single_threaded to replace __gthread_active_p
everywhere. If we replaced the uses of __gthread_active_p in std::mutex
then we would elide the pthread_mutex_lock in the code below, but not
the pthread_mutex_unlock:

  std::mutex m;
  m.lock();            // pthread_mutex_lock
  std::thread t([]{}); // __libc_single_threaded = false
  t.join();
  m.unlock();          // pthread_mutex_unlock

We need the lock and unlock to use the same "is threading enabled"
predicate, and similarly for init/destroy pairs for mutexes and
condition variables, so that we don't try to release resources that were
never acquired.

There are other places that could use __libc_single_threaded, such as
_Sp_locker in src/c++11/shared_ptr.cc and locale init functions, but
they can be changed later.

libstdc++-v3/ChangeLog:

	PR libstdc++/96817
	* include/ext/atomicity.h (__gnu_cxx::__is_single_threaded()):
	New function wrapping __libc_single_threaded if available.
	(__exchange_and_add_dispatch, __atomic_add_dispatch): Use it.
	* libsupc++/guard.cc (__cxa_guard_acquire, __cxa_guard_abort)
	(__cxa_guard_release): Likewise.
	* testsuite/18_support/96817.cc: New test.
2020-09-26 20:32:36 +01:00
GCC Administrator
cdd8f031c7 Daily bump. 2020-09-26 00:16:25 +00:00
Jonathan Wakely
473da7e22c libstdc++: Remove redundant -std=gnu++1z flags from makefile
Now that G++ defaults to gnu++17 we don't need special rules for
compiling the C++17 allocation and deallocation functions.

libstdc++-v3/ChangeLog:

	* libsupc++/Makefile.am: Remove redundant -std=gnu++1z flags.
	* libsupc++/Makefile.in: Regenerate.
2020-09-25 12:50:17 +01:00
GCC Administrator
a2b7397b50 Daily bump. 2020-09-25 00:16:27 +00:00
Antony Polukhin
c1fc9f6e10 libstdc++: assert that type traits are not misused with incomplete types [PR 71579]
libstdc++-v3/ChangeLog:

	PR libstdc++/71579
	* include/std/type_traits (invoke_result, is_invocable)
	(is_invocable_r, is_nothrow_invocable, is_nothrow_invocable_r):
	Add static_asserts to make sure that the arguments of the type
	traits are not misused with incomplete types.
	* testsuite/20_util/invoke_result/incomplete_args_neg.cc: New test.
	* testsuite/20_util/is_invocable/incomplete_args_neg.cc: New test.
	* testsuite/20_util/is_invocable/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc:
	New test.
	* testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc: Check
	for error on incomplete type usage in trait.
2020-09-24 18:51:37 +01:00
Patrick Palka
42907ca9a4 libstdc++: Specialize ranges::__detail::__box for semiregular types
The class template semiregular-box<T> defined in [range.semi.wrap] is
used by a number of views to accomodate non-semiregular subobjects
while ensuring that the overall view remains semiregular.  It provides
a stand-in default constructor, copy assignment operator and move
assignment operator whenever the underlying type lacks them.  The
wrapper derives from std::optional<T> to support default construction
when T is not default constructible.

It would be nice for this wrapper to essentially be a no-op when the
underlying type is already semiregular, but this is currently not the
case due to its use of std::optional<T>, which incurs space overhead
compared to storing just T.

To that end, this patch specializes the semiregular wrapper for
semiregular T.  Compared to the primary template, this specialization
uses less space, and it allows [[no_unique_address]] to optimize away
wrapped data members whose underlying type is empty and semiregular
(e.g. a non-capturing lambda).  This patch also applies
[[no_unique_address]] to the five data members that use the wrapper.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__boxable): Split out the
	associated constraints of __box into here.
	(__detail::__box): Use the __boxable concept.  Define a leaner
	partial specialization for semiregular types.
	(single_view::_M_value): Give it [[no_unique_address]].
	(filter_view::_M_pred): Likewise.
	(transform_view::_M_fun): Likewise.
	(take_while_view::_M_pred): Likewise.
	(drop_while_view::_M_pred):: Likewise.
	* testsuite/std/ranges/adaptors/detail/semiregular_box.cc: New
	test.
2020-09-24 12:58:39 -04:00