[Bug c++/63628] New: [c++1y] cannot use decltype on captured variable in generic lambda

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Oct 23 12:41:00 GMT 2014


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

            Bug ID: 63628
           Summary: [c++1y] cannot use decltype on captured variable in
                    generic lambda
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: daniel.kruegler at googlemail dot com, jason at gcc dot gnu.org,
                    oakad at yahoo dot com, tongari95 at gmail dot com
            Blocks: 54367

+++ This bug was initially created as a clone of Bug #61814 +++

The code below has a lambda that captures the outer params t, for forwarding
matter, decltype on t has to be used.
```
    auto const pack = [](auto&&... t)
    {
        return [&](auto&& f)->decltype(auto)
        {
            return f(static_cast<decltype(t)>(t)...);
        };
    };

    int main(int argc, char** argv) {
        pack(1)([](int){});
        return 0;
    }
```
It works with clang 3.5, but g++ 4.9.0 complains:
error: 't' was not declared in this scope

The same also applies to `sizeof` or that kind of compile-time thing.



More information about the Gcc-bugs mailing list