Bug 98832 - CTAD fails for alias template of aggregate with specified undeducible template parameter
Summary: CTAD fails for alias template of aggregate with specified undeducible templat...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.2
Assignee: Patrick Palka
URL: https://godbolt.org/z/M1eqvq
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2021-01-26 04:46 UTC by Johel Ernesto Guerrero Peña
Modified: 2021-07-13 14:07 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-06-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johel Ernesto Guerrero Peña 2021-01-26 04:46:23 UTC
See https://godbolt.org/z/M1eqvq.
```C++
template<class T,class U>struct X{U u;};
template<class T>using Y=X<int,T>;
Y y{0};
```
Comment 1 Patrick Palka 2021-06-24 14:18:46 UTC
Confirmed.  It looks like we're overlooking the aggregate deduction candidate for the underlying template when building the set of guides for the alias.
Comment 2 GCC Commits 2021-06-24 17:13:46 UTC
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:c761be53f6b62e22ac5de18c4aaf88648f64f5b7

commit r12-1793-gc761be53f6b62e22ac5de18c4aaf88648f64f5b7
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jun 24 13:11:44 2021 -0400

    c++: alias CTAD and aggregate deduction cand [PR98832]
    
    During alias CTAD, we're accidentally ignoring the aggregate deduction
    candidate for the underlying template because this guide is added
    separately via maybe_aggr_guide (which doesn't yet handle alias
    templates) instead of via deduction_guides_for (which does).  This patch
    makes maybe_aggr_guide handle alias templates in a manner similar to
    deduction_guides_for.
    
            PR c++/98832
    
    gcc/cp/ChangeLog:
    
            * pt.c (maybe_aggr_guide): Handle alias templates appropriately.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/class-deduction-alias9.C: New test.
Comment 3 GCC Commits 2021-07-13 14:03:28 UTC
The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:660cbbae327fbfa315e26d286b03efffc3c21cb5

commit r11-8730-g660cbbae327fbfa315e26d286b03efffc3c21cb5
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jun 24 13:11:44 2021 -0400

    c++: alias CTAD and aggregate deduction cand [PR98832]
    
    During alias CTAD, we're accidentally ignoring the aggregate deduction
    candidate for the underlying template because this guide is added
    separately via maybe_aggr_guide (which doesn't yet handle alias
    templates) instead of via deduction_guides_for (which does).  This patch
    makes maybe_aggr_guide handle alias templates in a manner similar to
    deduction_guides_for.
    
            PR c++/98832
    
    gcc/cp/ChangeLog:
    
            * pt.c (maybe_aggr_guide): Handle alias templates appropriately.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/class-deduction-alias9.C: New test.
    
    (cherry picked from commit c761be53f6b62e22ac5de18c4aaf88648f64f5b7)
Comment 4 Patrick Palka 2021-07-13 14:07:18 UTC
Fixed for 11.2/12