Thanks for your suggestions. I will apply them in the upcoming patch (v3).

On Mon, May 6, 2024 at 7:46 PM Patrick Palka <ppa...@redhat.com> wrote:
> We could also/instead consider defining
>
> int want = TEMPLATE_TYPE_ORIG_LEVEL (auto_node);
> int have = TMPL_ARGS_DEPTH (full_targs);
>
> and express the logic in terms of these instead of the possibly
> negative 'missing_levels'. The 'want < have' case could have a comment
> mentioning that this occurs for a constrained auto within an explicit
> specialization.)

I converted missing_levels into want and have variables. Additionally, I
added an assertion to explicitly state that our trimming logic assumes the
context to be one of adc_variable_type, adc_return_type, or adc_decomp_type.

> > > Note that, for the case where there are real missing levels, we are
> > > putting irrelevant template arguments for the missing levels instead
> > > of make_tree_vec(0). By this change:
> > > - If the type is independent of those missing levels: it works fine 
> > > either way.
> > > - If the type is dependent on those missing levels: Instead of raising
> > > an ICE, the compiler exhibits undefined behavior.
>
> Makes sense.

For the record, I have looked into the history of this hack to find out in
which scenarios we may have to deal with missing levels.
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b49d23f3e238c08bdbc5b892b2ed0a57b5f5caf9
As far as I can understand, it was limited to the adc_unify context at that
time, but it might have been changed since then. Since I was not sure about
it, I have not added an assertion for this case.

Many thanks!

Reply via email to