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

            Bug ID: 66538
           Summary: Parameter not in scope of generic lambda trailing
                    decltype
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldionne.2 at gmail dot com
  Target Milestone: ---

The following code does not compile on GCC trunk:

    auto f = [](auto&& x) -> decltype((void)x) { };

The failure is

     error: ‘x’ was not declared in this scope


Removing the && gives an internal compiler error as a bonus:

    auto f = [](auto x) -> decltype((void)x) { };

The failure is

    error: ‘x’ was not declared in this scope
         auto f = [](auto x) -> decltype((void)x) { };
                                               ^
    In lambda function:
    internal compiler error: in dependent_type_p, at cp/pt.c:21073
         auto f = [](auto x) -> decltype((void)x) { };
                                ^


Finally, please note that the following code compiles fine:

    auto f = [](auto&& x) -> decltype(static_cast<void>(x)) { };


Regards,
Louis Dionne

Reply via email to