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

            Bug ID: 86859
           Summary: error: expansion pattern contains no parameter pack
                    when a pack from introduced in a capture is used in
                    decltype
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gufideg at gmail dot com
  Target Milestone: ---

Here's the code snippet that triggers the bug:


    int main() {
        auto builder = [](auto b) {
            return [b](auto... treeArgs) {
                return [b, treeArgs...]()
                -> decltype(b(treeArgs...)) {
                    return b(treeArgs...);
                };
            };
        };
        builder([]{});
    }

GCC outputs a quite weird error message:

    In instantiation of 'main()::<lambda(auto:1)> [with auto:1 =
main()::<lambda()>]':
       required from here
    error: expansion pattern '#'nontype_argument_pack' not supported by
dump_expr#<expression error>' contains no parameter packs
                 -> decltype(b(treeArgs...)) {
                             ~^~~~~~~~~~~~~

This code compiles fine in clang.

Changing the `decltype(<expr>)` for a `decltype(auto)` work around the bug:


    int main() {
        auto builder = [](auto b) {
            return [b](auto... treeArgs) {
                return [b, treeArgs...]()
                -> decltype(auto) {
                    return b(treeArgs...);
                };
            };
        };
        builder([]{});
    }

Reply via email to