https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116739

            Bug ID: 116739
           Summary: template parameter confusion results in parameter
                    packs not expanded with '...'
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ted at lyncon dot se
  Target Milestone: ---

The following results in `error: parameter packs not expanded with '...'` in
all versions of g++ that I could test @ godbolt.com.

Changing the member function template to use a different name than `type` for
the parameter pack makes the program compile.
```
#include <iostream>
#include <optional>
#include <tuple>
#include <type_traits>

template <class... types>
struct type_or_tuple {
    using tup = std::tuple<types...>;
    using type = std::conditional_t<sizeof...(types) == 1,
                                    std::tuple_element_t<0, tup>, tup>;
};

template <class... types>
using type_or_tuple_t = typename type_or_tuple<types...>::type;

template <class... types>
class myclass {
    using payload_type = type_or_tuple_t<types...>;

    template <class... type>
    // error: parameter packs not expanded with '...':
    std::optional<payload_type> try_push(type&&... data) {
        payload_type t;
        std::optional<decltype(t)> o;

        return o;
    }
};

int main() { [[maybe_unused]] myclass<unsigned> c; }
```

Reply via email to