[Bug c++/70942] [c++14] Incorrect deduction of generic lambda `auto&&` parameter

rs2740 at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed May 4 09:38:00 GMT 2016


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

TC <rs2740 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rs2740 at gmail dot com

--- Comment #1 from TC <rs2740 at gmail dot com> ---
Reduced:

int main()
{
    int x = 0;
    [](auto&& xv){
        static_cast<decltype(xv)>(xv) = 1;
    }(x);
}

OK on GCC 5. Fails with a bogus error on 6 and 7:
main.cpp: In instantiation of 'main()::<lambda(auto:1&&)> [with auto:1 = int]':
main.cpp:5:17:   required by substitution of 'template<class auto:1>
main()::<lambda(auto:1&&)>::operator decltype
(((main()::<lambda(auto:1&&)>)0u).operator()(static_cast<auto:1&&>(<anonymous>)))
(*)(auto:1&&)() const [with auto:1 = int]'
main.cpp:7:8:   required from here
main.cpp:6:39: error: using xvalue (rvalue reference) as lvalue
         static_cast<decltype(xv)>(xv) = 1;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~


More information about the Gcc-bugs mailing list