[PATCH] libstdc++: Add missing std::move to join_view::iterator ctor [PR101483]

2021-07-23 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, does this look OK for trunk/branches? PR libstdc++/101483 libstdc++-v3/ChangeLog: * include/std/ranges (join_view::_Iterator::_Iterator): Add missing std::move. --- libstdc++-v3/include/std/ranges | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH] libstdc++: Fix up implementation of LWG 3533 [PR101589]

2021-07-23 Thread Patrick Palka via Gcc-patches
In r12-569 I accidentally applied the LWG 3533 change that was intended for elements_view::iterator::base to elements_view::base instead. This patch corrects this, and also applies the corresponding LWG 3533 change to lazy_split_view::inner-iter::base now that we implement P2210. Tested on

Re: [PATCH] c++: Improve memory usage of subsumption [PR100828]

2021-07-19 Thread Patrick Palka via Gcc-patches
On Mon, 19 Jul 2021, Patrick Palka wrote: > Constraint subsumption is implemented in two steps. The first step > computes the disjunctive (or conjunctive) normal form of one of the > constraints, and the second step verifies that each clause in the > decomposed form implies the other constraint.

[PATCH] c++: Improve memory usage of subsumption [PR100828]

2021-07-19 Thread Patrick Palka via Gcc-patches
Constraint subsumption is implemented in two steps. The first step computes the disjunctive (or conjunctive) normal form of one of the constraints, and the second step verifies that each clause in the decomposed form implies the other constraint. Performing these two steps separately is

Re: [PATCH] c++: argument pack expansion inside constraint [PR100138]

2021-07-15 Thread Patrick Palka via Gcc-patches
On Sat, May 8, 2021 at 8:42 AM Jason Merrill wrote: > > On 5/7/21 12:33 PM, Patrick Palka wrote: > > This PR is about CTAD but the underlying problems are more general; > > CTAD is a good trigger for them because of the necessary substitution > > into constraints that deduction guide generation

[PATCH] c++: covariant reference return type [PR99664]

2021-07-15 Thread Patrick Palka via Gcc-patches
This implements the wording changes of DR 960 which clarifies that two reference types are covariant only if they're both lvalue references or both rvalue references. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? DR 960 PR c++/99664

[PATCH] c++: alias CTAD inside decltype [PR101233]

2021-07-15 Thread Patrick Palka via Gcc-patches
This is the alias CTAD version of the CTAD bug PR93248, and the fix is the same: clear cp_unevaluated_operand so that the entire chain of DECL_ARGUMENTS gets substituted. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? PR c++/101233 gcc/cp/ChangeLog:

Re: [PATCH] c++: CTAD and forwarding references [PR88252]

2021-07-14 Thread Patrick Palka via Gcc-patches
On Wed, 14 Jul 2021, Jason Merrill wrote: > On 7/14/21 11:26 AM, Patrick Palka wrote: > > Here we're incorrectly treating T&& as a forwarding reference during > > CTAD even though T is a template parameter of the class template. > > > > This happens because the template parameter T in the

[PATCH] c++: CTAD and forwarding references [PR88252]

2021-07-14 Thread Patrick Palka via Gcc-patches
Here we're incorrectly treating T&& as a forwarding reference during CTAD even though T is a template parameter of the class template. This happens because the template parameter T in the out-of-line definition of the constructor doesn't have the flag TEMPLATE_TYPE_PARM_FOR_CLASS set, and during

[PATCH] libstdc++: invalid default init in _CachedPosition [PR101231]

2021-07-13 Thread Patrick Palka via Gcc-patches
The primary template for _CachedPosition is a dummy implementation for non-forward ranges, the iterators for which generally can't be cached. Because this implementation doesn't actually cache anything, _M_has_value is defined to be false and so calls to _M_get (which are always guarded by

[PATCH] libstdc++: Give split_view::_Sentinel a default ctor [PR101214]

2021-07-13 Thread Patrick Palka via Gcc-patches
This gives the new split_view's sentinel type a defaulted default constructor, something which was overlooked in r12-1665. This patch also fixes a couple of other issues with the new split_view as reported in the PR. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? PR

[PATCH] libstdc++: Give split_view::_Sentinel a default ctor [PR101214]

2021-07-13 Thread Patrick Palka via Gcc-patches
This gives the new split_view's sentinel type a defaulted default constructor, something which was overlooked in r12-1665. This patch also fixes a couple of other issues with the new split_view as reported in the PR. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? PR

Re: [PATCH] c++: permit deduction guides at class scope [PR79501]

2021-07-09 Thread Patrick Palka via Gcc-patches
On Fri, 9 Jul 2021, Jason Merrill wrote: > On 7/9/21 4:18 PM, Patrick Palka wrote: > > On Fri, 9 Jul 2021, Patrick Palka wrote: > > > > > On Fri, 9 Jul 2021, Jason Merrill wrote: > > > > > > > On 7/9/21 3:18 PM, Patrick Palka wrote: > > > > > This adds support for declaring (class-scope)

Re: [PATCH] c++: permit deduction guides at class scope [PR79501]

2021-07-09 Thread Patrick Palka via Gcc-patches
On Fri, 9 Jul 2021, Patrick Palka wrote: > On Fri, 9 Jul 2021, Jason Merrill wrote: > > > On 7/9/21 3:18 PM, Patrick Palka wrote: > > > This adds support for declaring (class-scope) deduction guides for a > > > member class template. Fortunately it seems only a couple of changes > > > are

Re: [PATCH] c++: permit deduction guides at class scope [PR79501]

2021-07-09 Thread Patrick Palka via Gcc-patches
On Fri, 9 Jul 2021, Jason Merrill wrote: > On 7/9/21 3:18 PM, Patrick Palka wrote: > > This adds support for declaring (class-scope) deduction guides for a > > member class template. Fortunately it seems only a couple of changes > > are needed in order for the existing CTAD machinery to handle

[PATCH] c++: permit deduction guides at class scope [PR79501]

2021-07-09 Thread Patrick Palka via Gcc-patches
This adds support for declaring (class-scope) deduction guides for a member class template. Fortunately it seems only a couple of changes are needed in order for the existing CTAD machinery to handle them like any other deduction guide: we need to make sure to give them a FUNCTION_TYPE instead of

[PATCH] c++: 'new T[N]' and SFINAE [PR82110]

2021-07-09 Thread Patrick Palka via Gcc-patches
Here we're failing to treat 'new T[N]' as erroneous in a SFINAE context when T isn't default constructible because expand_aggr_init_1 doesn't communicate to build_aggr_init (its only SFINAE caller) whether the initialization was actually successful. To fix this, this patch makes

Re: [PATCH] c++: requires-expr with dependent extra args [PR101181]

2021-07-09 Thread Patrick Palka via Gcc-patches
On Thu, 8 Jul 2021, Jason Merrill wrote: > On 7/8/21 11:28 AM, Patrick Palka wrote: > > Here we're crashing ultimately because the mechanism for delaying > > substitution into a requires-expression (or constexpr if) doesn't > > expect to see dependent args. But we end up capturing dependent > >

[PATCH] c++: requires-expr with dependent extra args [PR101181]

2021-07-08 Thread Patrick Palka via Gcc-patches
Here we're crashing ultimately because the mechanism for delaying substitution into a requires-expression (or constexpr if) doesn't expect to see dependent args. But we end up capturing dependent args here when substituting into the default template argument during coerce_template_parms for the

[PATCH] c++: Fix PR101247 in another way

2021-07-07 Thread Patrick Palka via Gcc-patches
r12-1989 fixed the testcase in the PR, but unfortunately the fix is buggy: 1. It breaks the case where the common template between the TEMPLATE_DECL t and ctx_parms is the innermost template (as in concepts-memtmpl5.C below). This can be fixed by instead passing the TREE_TYPE of

Re: [PATCH] c++: unqualified member template in constraint [PR101247]

2021-07-01 Thread Patrick Palka via Gcc-patches
On Thu, 1 Jul 2021, Jason Merrill wrote: > On 6/30/21 5:27 PM, Patrick Palka wrote: > > Here any_template_parm_r is failing to mark the template parameters > > that're implicitly used by the unqualified use of 'd' inside the constraint, > > because the code to do so assumes each level of a

[PATCH] c++: unqualified member template in constraint [PR101247]

2021-06-30 Thread Patrick Palka via Gcc-patches
Here any_template_parm_r is failing to mark the template parameters that're implicitly used by the unqualified use of 'd' inside the constraint, because the code to do so assumes each level of a template parameter list points to the corresponding primary template, but here the parameter level for

Re: [PATCH 2/2] c++: Extend PR96204 fix to variable templates

2021-06-30 Thread Patrick Palka via Gcc-patches
On Wed, 30 Jun 2021, Jason Merrill wrote: > On 6/30/21 10:48 AM, Patrick Palka wrote: > > On Tue, 29 Jun 2021, Jason Merrill wrote: > > > > > On 6/29/21 1:57 PM, Patrick Palka wrote: > > > > r12-1829 corrected the access scope during partial specialization > > > > matching of class templates,

Re: [PATCH] c++: CTAD within alias template [PR91911]

2021-06-30 Thread Patrick Palka via Gcc-patches
On Wed, Jun 30, 2021 at 3:51 PM Jason Merrill wrote: > > On 6/30/21 11:58 AM, Patrick Palka wrote: > > On Wed, 30 Jun 2021, Patrick Palka wrote: > > > >> On Fri, 25 Jun 2021, Jason Merrill wrote: > >> > >>> On 6/25/21 1:11 PM, Patrick Palka wrote: > On Fri, 25 Jun 2021, Jason Merrill wrote:

Re: [PATCH] c++: CTAD within alias template [PR91911]

2021-06-30 Thread Patrick Palka via Gcc-patches
On Wed, 30 Jun 2021, Patrick Palka wrote: > On Fri, 25 Jun 2021, Jason Merrill wrote: > > > On 6/25/21 1:11 PM, Patrick Palka wrote: > > > On Fri, 25 Jun 2021, Jason Merrill wrote: > > > > > > > On 6/24/21 4:45 PM, Patrick Palka wrote: > > > > > In the first testcase below, during parsing of

Re: [PATCH] c++: CTAD within alias template [PR91911]

2021-06-30 Thread Patrick Palka via Gcc-patches
On Fri, 25 Jun 2021, Jason Merrill wrote: > On 6/25/21 1:11 PM, Patrick Palka wrote: > > On Fri, 25 Jun 2021, Jason Merrill wrote: > > > > > On 6/24/21 4:45 PM, Patrick Palka wrote: > > > > In the first testcase below, during parsing of the alias template > > > > ConstSpanType, transparency of

Re: [PATCH 1/2] c++: Fix push_access_scope and introduce RAII wrapper for it

2021-06-30 Thread Patrick Palka via Gcc-patches
On Tue, 29 Jun 2021, Jason Merrill wrote: > On 6/29/21 1:57 PM, Patrick Palka wrote: > > When push_access_scope is passed a TYPE_DECL for a class type (which > > can happen during e.g. satisfaction), we undesirably push only the > > enclosing context of the class instead of the class itself.

Re: [PATCH 2/2] c++: Extend PR96204 fix to variable templates

2021-06-30 Thread Patrick Palka via Gcc-patches
On Tue, 29 Jun 2021, Jason Merrill wrote: > On 6/29/21 1:57 PM, Patrick Palka wrote: > > r12-1829 corrected the access scope during partial specialization > > matching of class templates, but neglected the variable template case. > > This patch moves the access scope adjustment to inside > >

[PATCH] c++: cxx_eval_array_reference and empty elt type [PR101194]

2021-06-29 Thread Patrick Palka via Gcc-patches
Here the initializer for 'x' is represented as an empty CONSTRUCTOR due to its empty element type. So during constexpr evaluation of the ARRAY_REF 'x[0]', we end up trying to lazily value initialize the omitted element at index 0, which fails because the element type is not default initializable.

[PATCH 1/2] c++: Fix push_access_scope and introduce RAII wrapper for it

2021-06-29 Thread Patrick Palka via Gcc-patches
When push_access_scope is passed a TYPE_DECL for a class type (which can happen during e.g. satisfaction), we undesirably push only the enclosing context of the class instead of the class itself. This causes us to mishandle e.g. testcase below due to us not entering the scope of A before checking

[PATCH 2/2] c++: Extend PR96204 fix to variable templates

2021-06-29 Thread Patrick Palka via Gcc-patches
r12-1829 corrected the access scope during partial specialization matching of class templates, but neglected the variable template case. This patch moves the access scope adjustment to inside most_specialized_partial_spec, so that all callers can benefit. Bootstrapped and regtested on

Re: [PATCH] c++: access scope during partial spec matching [PR96204]

2021-06-25 Thread Patrick Palka via Gcc-patches
On Fri, 25 Jun 2021, Jason Merrill wrote: > On 6/25/21 11:03 AM, Patrick Palka wrote: > > Here, when determining whether the partial specialization matches the > > specialization has_set_attr_method, we do so from the scope of > > where the template-id appears rather than from the scope of the >

Re: [PATCH] c++: CTAD within alias template [PR91911]

2021-06-25 Thread Patrick Palka via Gcc-patches
On Fri, 25 Jun 2021, Jason Merrill wrote: > On 6/24/21 4:45 PM, Patrick Palka wrote: > > In the first testcase below, during parsing of the alias template > > ConstSpanType, transparency of alias template specializations means we > > replace SpanType with SpanType's substituted definition. But

Re: [PATCH] c++: access scope during partial spec matching [PR96204]

2021-06-25 Thread Patrick Palka via Gcc-patches
On Fri, 25 Jun 2021, Patrick Palka wrote: > Here, when determining whether the partial specialization matches the > specialization has_set_attr_method, we do so from the scope of Er, this should say has_type_method. > where the template-id appears rather than from the scope of the >

[PATCH] c++: access scope during partial spec matching [PR96204]

2021-06-25 Thread Patrick Palka via Gcc-patches
Here, when determining whether the partial specialization matches the specialization has_set_attr_method, we do so from the scope of where the template-id appears rather than from the scope of the specialization, and this causes us to select the partial specialization (since Child::type is

[PATCH] c++: CTAD within alias template [PR91911]

2021-06-24 Thread Patrick Palka via Gcc-patches
In the first testcase below, during parsing of the alias template ConstSpanType, transparency of alias template specializations means we replace SpanType with SpanType's substituted definition. But this substitution lowers the level of the CTAD placeholder for span(T()) from 2 to 1, and so the

Re: [committed] libstdc++: Implement LWG 2762 for std::unique_ptr::operator*

2021-06-24 Thread Patrick Palka via Gcc-patches
On Thu, 24 Jun 2021, Jonathan Wakely via Libstdc++ wrote: > The LWG issue proposes to add a conditional noexcept-specifier to > std::unique_ptr's dereference operator. The issue is currently in > Tentatively Ready status, but even if it isn't voted into the draft, we > can do it as a conforming

[PATCH] c++: alias CTAD and aggregate deduction cand [PR98832]

2021-06-24 Thread Patrick Palka via Gcc-patches
During alias CTAD, we're accidentally ignoring the aggregate deduction candidate of the underlying template because it's added to the candidate set separately via maybe_aggr_guide (which doesn't yet handle alias templates) rather than via deduction_guides_for (which does). This patch makes

[PATCH] c++: requires-expression folding [PR101182]

2021-06-23 Thread Patrick Palka via Gcc-patches
Here we're crashing because cp_fold_function walks into the (templated) requirements of a requires-expression outside a template, but the folding routines aren't prepared to handle templated trees. This patch fixes this by making cp_fold use evaluate_requires_expr to fold a requires-expression as

Re: [PATCH] c++: excessive instantiation during CTAD [PR101174]

2021-06-23 Thread Patrick Palka via Gcc-patches
On Wed, 23 Jun 2021, Jason Merrill wrote: > On 6/23/21 2:18 PM, Patrick Palka wrote: > > We set DECL_CONTEXT on implicitly generated deduction guides so that > > their access is consistent with that of the constructor. But this > > apparently leads to excessive instantiation in some cases,

[PATCH] c++: excessive instantiation during CTAD [PR101174]

2021-06-23 Thread Patrick Palka via Gcc-patches
We set DECL_CONTEXT on implicitly generated deduction guides so that their access is consistent with that of the constructor. But this apparently leads to excessive instantiation in some cases, ultimately because instantiation of a deduction guide should be independent of instantiation of the

Re: [PATCH] c++: CTAD and deduction guide selection [PR86439]

2021-06-22 Thread Patrick Palka via Gcc-patches
On Tue, 22 Jun 2021, Jonathan Wakely wrote: > On Tue, 22 Jun 2021 at 19:45, Patrick Palka wrote: > > This change causes us to reject some container CTAD examples in the > > libstdc++ testsuite due to deduction failure for {}, which AFAICT is the > > correct behavior. Previously, in the case of

[PATCH] c++: CTAD and deduction guide selection [PR86439]

2021-06-22 Thread Patrick Palka via Gcc-patches
During CTAD, we select the best viable deduction guide via build_new_function_call, which performs overload resolution on the set of candidate guides and then forms a call to the guide. As the PR points out, this latter step is unnecessary and occasionally gives us the wrong answer since a call

[PATCH] libstdc++: Sync __cpp_lib_ranges macro defined in ranges_cmp.h

2021-06-21 Thread Patrick Palka via Gcc-patches
r12-1606 bumped the value of __cpp_lib_ranges defined in , but this macro is also defined in , so it needs to be updated there too. libstdc++-v3/ChangeLog: * include/bits/ranges_cmp.h (__cpp_lib_ranges): Adjust value. --- libstdc++-v3/include/bits/ranges_cmp.h | 2 +- 1 file changed, 1

[PATCH] c++: REF_PARENTHESIZED_P wrapper inhibiting NRVO [PR67302]

2021-06-19 Thread Patrick Palka via Gcc-patches
Here, in C++14 or later, we remember the parentheses around 'a' in the return statement by using a REF_PARENTHESIZED_P wrapper, which ends up inhibiting NRVO because we don't look through this wrapper before checking the conditions for NRVO. This patch fixes this by calling

[PATCH] c++: conversion to base of vbase in NSDMI [PR80431]

2021-06-18 Thread Patrick Palka via Gcc-patches
The delayed processing of conversions to a virtual base inside an NSDMI assumes the target base type is a (possibly indirect) virtual base of the current class, but the target base type could also be an indirect non-virtual base inherited from a virtual base, as in the testcase below. Since such a

Re: [PATCH] libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

2021-06-18 Thread Patrick Palka via Gcc-patches
On Wed, 5 May 2021, Patrick Palka wrote: > On Wed, 5 May 2021, Patrick Palka wrote: > > > On Wed, 5 May 2021, Jonathan Wakely wrote: > > > > > On 04/05/21 21:42 -0400, Patrick Palka via Libstdc++ wrote: > > > > This rewrites ranges::minmax and ranges::minmax_element so that it > > > > performs

[PATCH] libstdc++: Implement LWG 3557 change to convertible_to

2021-06-18 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * include/std/concepts (convertible_to): Just use declval as per LWG 3557. --- libstdc++-v3/include/std/concepts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts

[PATCH] libstdc++: Implement LWG 3555 changes to transform/elements_view

2021-06-17 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * include/std/ranges (transform_view::_Iterator::_S_iter_concept): Consider _Base instead of _Vp as per LWG 3555. (elements_view::_Iterator::_S_iter_concept): Likewise. --- libstdc++-v3/include/std/ranges | 12 ++-- 1 file changed, 6

[PATCH] libstdc++: Implement LWG 3553 change to split_view

2021-06-17 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * include/std/ranges (split_view::_OuterIter::value_type::begin): Remove the non-const overload, and remove the copyable constraint on the const overload as per LWG 3553. --- libstdc++-v3/include/std/ranges | 6 -- 1 file changed, 6

[PATCH] libstdc++: Implement LWG 3546 changes to common_iterator

2021-06-17 Thread Patrick Palka via Gcc-patches
libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__detail::__common_iter_use_postfix_proxy): Add move_constructible constraint as LWG 3546. (common_iterator::__postfix_proxy): Adjust initializer of _M_keep as per LWG 3546. ---

[PATCH 3/5] libstdc++: Rename views::split to views::lazy_split as per P2210

2021-06-17 Thread Patrick Palka via Gcc-patches
This mostly mechanical patch performs the renaming part of P2210R3 "Superior string splitting". It also defines _InnerIter::base() overloads. libstdc++-v3/ChangeLog: * include/std/ranges: Rename views::split to views::lazy_split, split_view to lazy_split_view, etc. throughout.

[PATCH 5/5] libstdc++: Implement new views::split as per P2210

2021-06-17 Thread Patrick Palka via Gcc-patches
This implements the new views::split as specified by P2210R2 "Superior string splitting". libstdc++-v3/ChangeLog: * include/std/ranges (__non_propagating_cache::operator bool): Define. (split_view): Define as per P2210. (views::__detail::__can_split_view): Define.

[PATCH 4/5] libstdc++: Implement resolution of LWG 3478 as per P2210

2021-06-17 Thread Patrick Palka via Gcc-patches
This implements the part of P2210R2 "Superior String Splitting" that resolves LWG 3478 for split_view (now named lazy_split_view). libstdc++-v3/ChangeLog: * include/std/ranges (lazy_split_view::_OuterIter::__at_end): Check _M_trailing_empty.

[PATCH 1/5] libstdc++: Implement P2325 changes to default-constructibilty of views

2021-06-17 Thread Patrick Palka via Gcc-patches
This implements the wording changes of P2325R3 "Views should not be required to be default constructible". Changes are relatively straightforward, besides perhaps those to __box (which now stands for copyable-box instead of semiregular-box) and __non_propagating_cache. For __box, this patch

[PATCH 2/5] libstdc++: Move ranges algos used by into ranges_util.h

2021-06-17 Thread Patrick Palka via Gcc-patches
The header defines simplified copies of some ranges algorithms in order to avoid including the entirety of ranges_algo.h. A subsequent patch is going to want to use ranges::search in as well, but that algorithm is more complicated compared to the other copied ones. So rather than additionally

Re: [PATCH 2/1] libstdc++: Non-triv-copyable extra args aren't simple [PR100940]

2021-06-15 Thread Patrick Palka via Gcc-patches
On Tue, 15 Jun 2021, Patrick Palka wrote: > This force-enables perfect forwarding call wrapper semantics whenever > the extra arguments of a partially applied range adaptor aren't all > trivially copyable, so as to avoid incurring unnecessary copies of > potentially expensive-to-copy objects

[PATCH 2/1] libstdc++: Non-triv-copyable extra args aren't simple [PR100940]

2021-06-15 Thread Patrick Palka via Gcc-patches
This force-enables perfect forwarding call wrapper semantics whenever the extra arguments of a partially applied range adaptor aren't all trivially copyable, so as to avoid incurring unnecessary copies of potentially expensive-to-copy objects (such as std::function objects) when invoking the

[PATCH] libstdc++: Refine range adaptors' "simple extra args" mechanism [PR100940]

2021-06-14 Thread Patrick Palka via Gcc-patches
The _S_has_simple_extra_args mechanism is used to simplify forwarding of range adaptor's extra arguments when perfect forwarding call wrapper semantics isn't required for correctness, on a per-adaptor basis. Both views::take and views::drop are flagged as such, but it turns out perfect forwarding

Re: [PATCH] c++: Substitute into function parms in lexical order [PR96560]

2021-06-11 Thread Patrick Palka via Gcc-patches
On Thu, Apr 29, 2021 at 7:48 AM Patrick Palka wrote: > > On Wed, 28 Apr 2021, Jason Merrill wrote: > > > On 4/28/21 2:24 PM, Patrick Palka wrote: > > > This makes tsubst_arg_types substitute into a function's parameter types > > > in left-to-right order instead of right-to-left order, in

Re: [PATCH] c++: normalization of non-templated return-type-req [PR100946]

2021-06-10 Thread Patrick Palka via Gcc-patches
On Thu, 10 Jun 2021, Jason Merrill wrote: > On 6/9/21 3:34 PM, Patrick Palka wrote: > > Here the satisfaction cache is conflating the satisfaction value of the > > two return-type-requirements because the corresponding constrained > > 'auto's have level 2, but they capture an empty

Re: [PATCH] c++: matching deduced template template parameters [PR67829]

2021-06-10 Thread Patrick Palka via Gcc-patches
On Thu, 10 Jun 2021, Jason Merrill wrote: > On 6/9/21 3:34 PM, Patrick Palka wrote: > > During deduction, when the template of a BOUND_TEMPLATE_TEMPLATE_PARM is > > a template template parameter, we need to consider the > > TEMPLATE_TEMPLATE_PARAMETER rather than the TEMPLATE_DECL thereof, > >

Re: [PATCH] c++: matching deduced template template parameters [PR67829]

2021-06-09 Thread Patrick Palka via Gcc-patches
On Wed, 9 Jun 2021, Patrick Palka wrote: > During deduction, when the template of a BOUND_TEMPLATE_TEMPLATE_PARM is Ah sorry, this should instead say "when the template of _the argument for_ a BOUND_TEMPLATE_TEMPLATE_PARM is ..." > a template template parameter, we need to consider the >

[PATCH] c++: normalization of non-templated return-type-req [PR100946]

2021-06-09 Thread Patrick Palka via Gcc-patches
Here the satisfaction cache is conflating the satisfaction value of the two return-type-requirements because the corresponding constrained 'auto's have level 2, but they capture an empty current_template_parms. This ultimately causes the satisfaction cache to think the type constraint doesn't

[PATCH] c++: matching deduced template template parameters [PR67829]

2021-06-09 Thread Patrick Palka via Gcc-patches
During deduction, when the template of a BOUND_TEMPLATE_TEMPLATE_PARM is a template template parameter, we need to consider the TEMPLATE_TEMPLATE_PARAMETER rather than the TEMPLATE_DECL thereof, because the canonical form of a template template parameter in a template argument list is the

[PATCH] c++: access of dtor named by qualified template-id [PR100918]

2021-06-04 Thread Patrick Palka via Gcc-patches
Here, when resolving the destructor named by Inner::~Inner (which is valid only before C++20) we end up in cp_parser_lookup_name to look up the name Inner relative to the scope Inner. The lookup naturally finds the injected-class-name Inner, and because is_template is true, we adjust this lookup

[PATCH] c++: tsubst_function_decl and excess arg levels [PR100102]

2021-06-03 Thread Patrick Palka via Gcc-patches
Here, when instantiating the dependent alias template duration::__is_harmonic with args={{T,U},{int}}, we find ourselves substituting the function decl _S_gcd. Since we have more arg levels than _S_gcd has parm levels, an old special case in tsubst_function_decl causes us to unwantedly reduce

Re: [PATCH] c++: top-level cv-quals on type of NTTP [PR100893]

2021-06-03 Thread Patrick Palka via Gcc-patches
On Thu, 3 Jun 2021, Patrick Palka wrote: > Here, we're rejecting the specialization of g with T=A, F= in the > first testcase due to a spurious constness mismatch between the type of > the template argument and the substituted type of F (the substituted > type has a top-level const). Note that

[PATCH] c++: top-level cv-quals on type of NTTP [PR100893]

2021-06-03 Thread Patrick Palka via Gcc-patches
Here, we're rejecting the specialization of g with T=A, F= in the first testcase due to a spurious constness mismatch between the type of the template argument and the substituted type of F (the substituted type has a top-level const). Note that this mismatch doesn't occur with object pointers

Re: [PATCH] c++: cv-qualified dependent name of alias tmpl [PR100592]

2021-06-02 Thread Patrick Palka via Gcc-patches
On Wed, 2 Jun 2021, Jason Merrill wrote: > On 6/2/21 4:56 PM, Patrick Palka wrote: > > On Wed, 2 Jun 2021, Patrick Palka wrote: > > > > > On Wed, 2 Jun 2021, Jason Merrill wrote: > > > > > > > On 6/2/21 2:39 PM, Patrick Palka wrote: > > > > > Here, the dependent template name in the return type

Re: [PATCH] c++: cv-qualified dependent name of alias tmpl [PR100592]

2021-06-02 Thread Patrick Palka via Gcc-patches
On Wed, 2 Jun 2021, Patrick Palka wrote: > On Wed, 2 Jun 2021, Jason Merrill wrote: > > > On 6/2/21 2:39 PM, Patrick Palka wrote: > > > Here, the dependent template name in the return type of f() resolves to > > > an alias of int& after substitution, and we end up complaining about > > >

Re: [PATCH] c++: cv-qualified dependent name of alias tmpl [PR100592]

2021-06-02 Thread Patrick Palka via Gcc-patches
On Wed, 2 Jun 2021, Jason Merrill wrote: > On 6/2/21 2:39 PM, Patrick Palka wrote: > > Here, the dependent template name in the return type of f() resolves to > > an alias of int& after substitution, and we end up complaining about > > qualifying this reference type with 'const' from

[PATCH] c++: cv-qualified dependent name of alias tmpl [PR100592]

2021-06-02 Thread Patrick Palka via Gcc-patches
Here, the dependent template name in the return type of f() resolves to an alias of int& after substitution, and we end up complaining about qualifying this reference type with 'const' from cp_build_qualified_type rather than just silently dropping the qualification as per [dcl.ref]/1. We already

[PATCH] c++: using-enum and access specifiers [PR100862]

2021-06-02 Thread Patrick Palka via Gcc-patches
When copying the enumerators imported by a class-scope using-enum declaration, we need to override current_access_specifier so that finish_member_declaration gives them the same access as the using-enum decl. The processing of a using-enum is performed after we've seen the entire definition of

[PATCH] c++: value init vs zero init in expand_aggr_init_1 [PR65816]

2021-06-01 Thread Patrick Palka via Gcc-patches
In the case of value-initializing an object of class type T, [dcl.init.general]/8 says: - if T has either no default constructor ([class.default.ctor]) or a default constructor that is user-provided or deleted, then the object is default-initialized; - otherwise, the object is

[PATCH] c++: parameter pack inside static_assert [PR99893]

2021-05-27 Thread Patrick Palka via Gcc-patches
Here, we're not finding the parameter pack inside the static_assert because STATIC_ASSERT trees are tcc_exceptional, and we weren't explicitly walking them in cp_walk_subtrees. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/cp/ChangeLog: PR c++/99893

Re: [PATCH] libstdc++: Avoid hard error in ranges::unique_copy [PR100770]

2021-05-27 Thread Patrick Palka via Gcc-patches
On Wed, 26 May 2021, Tim Song wrote: > On Wed, May 26, 2021 at 1:43 PM Patrick Palka wrote: > > > > On Wed, 26 May 2021, Tim Song wrote: > > > > > > On Wed, May 26, 2021 at 12:00 PM Patrick Palka via Libstdc++ > > > wrote: > > > > > > > > - else if constexpr (input_iterator<_Out> > > > >

[PATCH] c++: Relax rules for non-type arguments in partial specs [CWG1315]

2021-05-26 Thread Patrick Palka via Gcc-patches
This implements the wording changes of CWG 1315, which permits non-type template arguments in a partial specialization to use template parameters more freely. Delightfully, it seems the only change needed is to remove a few checks from process_partial_specialization. But that change alone

Re: [PATCH] libstdc++: Simplify range adaptors' forwarding of bound args when possible

2021-05-26 Thread Patrick Palka via Gcc-patches
On Fri, 14 May 2021, Patrick Palka wrote: > r11-8053 rewrote the range adaptor implementation in conformance with > P2281, making partial application act like a SFINAE-friendly perfect > forwarding call wrapper. Making SFINAE-friendliness coexist with > perfect forwarding here requires adding

Re: [PATCH] libstdc++: Avoid hard error in ranges::unique_copy [PR100770]

2021-05-26 Thread Patrick Palka via Gcc-patches
On Wed, 26 May 2021, Tim Song wrote: > I noticed that output_iterator_wrapper still has a (non-void) > value_type. Perhaps we can get better coverage if it doesn't have one? > The existing tests should have caught this case with that change, at least. Good point, and I guess it should be fine to

[PATCH] libstdc++: Avoid hard error in ranges::unique_copy [PR100770]

2021-05-26 Thread Patrick Palka via Gcc-patches
When input_iterator<_Out> isn't satisfied, we need to avoid substituting into iter_value_t<_Out> because the latter isn't necessarily well-formed in that case. To that end, this patch rewrites the problematic condition in ranges::unique_copy into a nested requirement which has the correct

Re: [PATCH] c++: access for hidden friend of nested class template [PR100502]

2021-05-26 Thread Patrick Palka via Gcc-patches
On Tue, 25 May 2021, Jason Merrill wrote: > On 5/25/21 10:50 AM, Patrick Palka wrote: > > On Mon, 24 May 2021, Jason Merrill wrote: > > > > > On 5/21/21 4:35 PM, Patrick Palka wrote: > > > > Here, during ahead of time access checking for the private member > > > > EnumeratorRange::end_reached_

Re: [PATCH] c++: constexpr and copy elision within mem init [PR100368]

2021-05-25 Thread Patrick Palka via Gcc-patches
On Mon, 24 May 2021, Jason Merrill wrote: > On 5/24/21 1:48 PM, Patrick Palka wrote: > > In the testcase below, the initializer for C::b inside C's default > > constructor is encoded as a TARGET_EXPR wrapping the CALL_EXPR f() in > > C++17 mode. During massaging of this constexpr constructor, >

Re: [PATCH] c++: access for hidden friend of nested class template [PR100502]

2021-05-25 Thread Patrick Palka via Gcc-patches
On Mon, 24 May 2021, Jason Merrill wrote: > On 5/21/21 4:35 PM, Patrick Palka wrote: > > Here, during ahead of time access checking for the private member > > EnumeratorRange::end_reached_ in the hidden friend f, we're triggering > > the the assert in enforce_access that verifies we're not trying

[PATCH] c++: constexpr and copy elision within mem init [PR100368]

2021-05-24 Thread Patrick Palka via Gcc-patches
In the testcase below, the initializer for C::b inside C's default constructor is encoded as a TARGET_EXPR wrapping the CALL_EXPR f() in C++17 mode. During massaging of this constexpr constructor, build_target_expr_with_type called from bot_manip ends up trying to use B's implicitly deleted copy

[PATCH] c++: access for hidden friend of nested class template [PR100502]

2021-05-21 Thread Patrick Palka via Gcc-patches
Here, during ahead of time access checking for the private member EnumeratorRange::end_reached_ in the hidden friend f, we're triggering the the assert in enforce_access that verifies we're not trying to add a dependent access check to TI_DEFERRED_ACCESS_CHECKS. The special thing about this class

[PATCH] c++: Fix reference NTTP binding to noexcept fn [PR97420]

2021-05-21 Thread Patrick Palka via Gcc-patches
Here, in C++17 mode, convert_nontype_argument_function is rejecting binding a non-noexcept function reference template parameter to a noexcept function (encoded as the template argument '*(int (&) (int)) '). The first roadblock to making this work is that the argument is wrapped an an implicit

[committed] libstdc++: Implement LWG 3490 change to drop_while_view::begin()

2021-05-20 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, committed to trunk as obvious. libstdc++-v3/ChangeLog: PR libstdc++/100606 * include/std/ranges (drop_while_view::begin): Assert the precondition added by LWG 3490. --- libstdc++-v3/include/std/ranges | 1 + 1 file changed, 1 insertion(+)

[PATCH] libstdc++: Fix access issue in iota_view::_Sentinel [PR100690]

2021-05-20 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, does this look OK for trunk/11/10? libstdc++-v3/ChangeLog: PR libstdc++/100690 * include/std/ranges (iota_view::_Sentinel::_M_distance_from): Split out into this member function from ... (iota_view::_Sentinel::operator-): ... here,

[PATCH] libstdc++: Support range adaptors with defaultable arguments

2021-05-20 Thread Patrick Palka via Gcc-patches
This adds support for defining range adaptors with defaultable arguments. No such range adaptors have yet been standardized, but range-v3 has a couple, e.g. 'unique' and 'sample' (which are approximately implemented in the added testcase), and it would be good to preemptively support such

Re: [PATCH] libstdc++: Implement missing P0896 changes to reverse_view [PR100639]

2021-05-18 Thread Patrick Palka via Gcc-patches
On Tue, 18 May 2021, Patrick Palka wrote: > This implements the P0896 changes to reverse_view's member types Whoops, s/reverse_view/reverse_iterator rather... consider this typo fixed throughout. > value_type, difference_type and reference in C++20 mode, which fixes > problems taking the

[PATCH] libstdc++: Implement missing P0896 changes to reverse_view [PR100639]

2021-05-18 Thread Patrick Palka via Gcc-patches
This implements the P0896 changes to reverse_view's member types value_type, difference_type and reference in C++20 mode, which fixes problems taking the reverse_iterator of an iterator with a non-integral difference_type (such as iota_view). Tested on x86_64-pc-linux-gnu, does this look OK for

[committed] libstdc++: Fix access issue in elements_view::_Sentinel [PR100631]

2021-05-18 Thread Patrick Palka via Gcc-patches
In the earlier commit r12-854 I forgot to also rewrite the other operator- overload in terms of the split-out member function _M_distance_from. Tested on x86_64-pc-linux-gnu, committed as obvious. libstdc++-v3/ChangeLog: PR libstdc++/100631 * include/std/ranges

Re: [PATCH] libstdc++: Fix iterator caching inside range adaptors [PR100479]

2021-05-17 Thread Patrick Palka via Gcc-patches
On Mon, 17 May 2021, Tim Song wrote: > On Mon, May 17, 2021 at 2:59 PM Patrick Palka wrote: > > > > + constexpr _CachedPosition& > > + operator=(_CachedPosition&& __other) noexcept > > + { > > + if (std::__addressof(__other) != this) > > I don't think we need this

Re: [PATCH] libstdc++: Fix access issues in elements_view::_Sentinel [PR100631]

2021-05-17 Thread Patrick Palka via Gcc-patches
On Mon, 17 May 2021, Tim Song wrote: > On Mon, May 17, 2021 at 12:21 PM Patrick Palka via Gcc-patches > wrote: > > > > using _Base = elements_view::_Base<_Const>; > > sentinel_t<_Base> _M_end = sentinel_t<_Base>(); > >

Re: [PATCH] libstdc++: Fix iterator caching inside range adaptors [PR100479]

2021-05-17 Thread Patrick Palka via Gcc-patches
On Mon, 17 May 2021, Tim Song wrote: > On Mon, May 17, 2021 at 11:46 AM Patrick Palka via Libstdc++ > wrote: > > constexpr void > > _M_set(const _Range&, const iterator_t<_Range>& __it) > > { > > __glibcxx_assert(!_M_has_value()); > > - _M_iter = __it; >

[PATCH] libstdc++: Fix condition for memoizing reverse_view::begin() [PR100621]

2021-05-17 Thread Patrick Palka via Gcc-patches
A range being a random access range is not a sufficient condition for ranges::next(iter, sent) to have constant time complexity; the range must also have a sized sentinel. This adjusts the memoization condition for reverse_view accordingly. Tested on x86_64-pc-linxu-gnu, does this look OK for

[PATCH] libstdc++: Fix access issues in elements_view::_Sentinel [PR100631]

2021-05-17 Thread Patrick Palka via Gcc-patches
Tested on x86_64-pc-linux-gnu, does this look OK for 10/11/trunk? libstdc++-v3/ChangeLog: PR libstdc++/100631 * include/std/ranges (elements_view::_Iterator): Befriend _Sentinel. (elements_view::_Sentinel::_M_equal): Templatize.

[PATCH] libstdc++: Fix up semiregular-box partial specialization [PR100475]

2021-05-17 Thread Patrick Palka via Gcc-patches
This makes the in-place constructor of our partial specialization of __box for already-semiregular types to use direct-non-list-initialization (in accordance with the specification of the primary template), and additionally makes its data() member function use std::__addressof. Tested on

[PATCH] libstdc++: Fix iterator caching inside range adaptors [PR100479]

2021-05-17 Thread Patrick Palka via Gcc-patches
This fixes two issues with our iterator caching as described in detail in the PR. Since r12-336 added the __non_propagating_cache class template as part of P2328, this patch just rewrites the _CachedPosition partial specialization in terms of this class template. Tested on x86_64-pc-linux-gnu,

<    4   5   6   7   8   9   10   11   12   13   >