Bug 108090 - pack expansion of using declarations doesn't properly handle dependent conversion function names
Summary: pack expansion of using declarations doesn't properly handle dependent conver...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 13.0
Assignee: Patrick Palka
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2022-12-14 00:15 UTC by Richard Smith
Modified: 2022-12-15 23:51 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2022-12-14 00:15:10 UTC
Testcase, which I believe is valid, and other compilers accept:

template<typename T> struct As { operator T(); };
template<typename ...T> struct AsAll : As<T>... {
  using As<T>::operator T...;
};
AsAll<int, float, char> x;

But GCC rejects:

<source>:3:26: error: parameter packs not expanded with '...':
    3 |   using As<T>::operator T...;
      |                          ^~~
<source>:3:26: note:         'T'
Comment 1 GCC Commits 2022-12-15 23:50:40 UTC
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

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

commit r13-4734-ge79d51963378b10ab90544a7d8eeb6266e9a57f6
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Dec 15 18:50:16 2022 -0500

    c++: variadic using-decl with parm pack in terminal name [PR102104]
    
    There's a curious corner case with variadic member using-decls: the
    terminal name can also contain a parameter pack, and only through naming
    a conversion function, e.g.
    
      using A<Ts>::operator Ts...;
    
    We currently only handle parameter packs appearing in the qualifying
    scope of a variadic using-decl; this patch adds support for the above
    case as well, representing such a using-decl via two pack expansions,
    one for the qualifying scope and one for the terminal name (despite
    logically there being just one).  Then at instantiation time we manually
    merge them.
    
            PR c++/102104
            PR c++/108090
    
    gcc/cp/ChangeLog:
    
            * error.cc (dump_decl) <case USING_DECL>: Look through a
            pack expansion in the name as well.
            * parser.cc (cp_parser_using_declaration): Handle a parameter
            pack appearing in the terminal name of a variadic using-decl.
            * pt.cc (tsubst_decl) <case USING_DECL>: Likewise.  Combine the
            handling of variadic and non-variadic using-decls.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1z/using-variadic1.C: New test.
            * g++.dg/cpp1z/using-variadic1a.C: New test.
            * g++.dg/cpp1z/using-variadic1b.C: New test.
            * g++.dg/cpp1z/using-variadic1c.C: New test.
            * g++.dg/cpp1z/using-variadic2.C: New test.
            * g++.dg/cpp1z/using-variadic3.C: New test.
Comment 2 Patrick Palka 2022-12-15 23:51:51 UTC
Fixed for GCC 13