On 3/1/24 10:17, Patrick Palka wrote:
On Fri, 1 Mar 2024, Jason Merrill wrote:

On 2/29/24 14:17, Patrick Palka wrote:
On Wed, 28 Feb 2024, Jason Merrill wrote:
I wonder about, rather than returning it directly, setting its level to 1
for
the substitution?

Done, that works nicely.

Then I wonder if it would be feasible to give all autos level 0 and adjust
it
here?  That's probably not a stage 4 change, though...

It seems feasible.  I experimented doing this in the past[1] and ran
into two complications.  One complication was with constrained auto
deduction, e.g.

    template<class T>
    void g() {
      C<T*> auto x = ...;
    };

Here the underlying concept-id that we enter satisfaction with is
C<auto, T*> where this auto has level one greater than the template
depth, and the argument vector we pass has an extra innermost level
containing the deduced type, so things match up nicely.  This seems
to be the only place where we truly need auto to have a non 0/1 level.
In my WIP patch in that thread I just made do_auto_deduction build the
concept-id C<auto, T*> in terms of an auto of the proper level before
entering satisfaction, which was kind of ugly but worked.

So maybe set its level to TMPL_ARGS_DEPTH (targs) after add_to_template_args,
rather than 1?

AFAICT in-place type modification in this case would be unsafe or at
least difficult to reason about due to the satisfaction/normalization
caches.  We would cache the result as if the auto had the nonzero level
and then (presumably) reset its level back to 0 afterward, leaving the
hash tables in an inconsistent state.

Hmm, sure.

Anyway, the second patch is OK.

Jason

Reply via email to