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

Karol Wozniak <karol.wozniak at email dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |5.3.1

--- Comment #1 from Karol Wozniak <karol.wozniak at email dot com> ---
minimal reproducible example

void foo(int &) {}

int main() {
  int a;
  [](auto &&x) { foo(static_cast<decltype(x) &&>(x)); }(a);
  return 0;
}

$ g++-6 -std=c++14 prog.cc 
prog.cc: In instantiation of ‘main()::<lambda(auto:1&&)> [with auto:1 = int]’:
prog.cc:5:14:   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]’
prog.cc:5:58:   required from here
prog.cc:5:21: error: invalid initialization of non-const reference of type
‘int&’ from an rvalue of type ‘int’
   [](auto &&x) { foo(static_cast<decltype(x) &&>(x)); }(a);
                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cc:1:6: note:   initializing argument 1 of ‘void foo(int&)’
 void foo(int &) {}
      ^~~

Reply via email to