diff --git a/share/libc++/utility b/share/libc++/utility index 8fe1d405af09b02bab6f57a1057be9d7d5e7f93f..9d7c32f81de1e71fe774ff487d4455adb7ccdcaa 100644 --- a/share/libc++/utility +++ b/share/libc++/utility @@ -55,7 +55,7 @@ namespace std { } template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept { - return t; + return static_cast<T&&>(t); } template <class T> typename remove_reference<T>::type&& move(T&& t) noexcept { diff --git a/tests/stl/oracle/stl_utility.res.oracle b/tests/stl/oracle/stl_utility.res.oracle index 490681e8e68366c761c814632318563dde331f70..78c5f1a2a2368bda0aaf5909956898ddf738fffc 100644 --- a/tests/stl/oracle/stl_utility.res.oracle +++ b/tests/stl/oracle/stl_utility.res.oracle @@ -679,6 +679,13 @@ _Bool *forward<bool>(type *t) return t; } +/*@ requires \valid(t); + ensures \valid(\result); */ +int *forward<int>(type *t) +{ + return t; +} + /*@ requires \valid(t); ensures \valid(\result); */ type *move<int>(int *t) @@ -989,6 +996,7 @@ int f(int x) int __retres; int A[2]; int B[2]; + int *xr; int *u; type *tmp_4; type *tmp_5; @@ -1018,30 +1026,32 @@ int f(int x) swap<int,2>(& A,& B); int *z = forward<int>(& x); int *t = forward<int>(z); - int __clang_tmp_2 = 42; - u = move<int>(& __clang_tmp_2); + type __clang_tmp_2 = x + 1; + xr = forward<int>(& __clang_tmp_2); + int __clang_tmp_3 = 42; + u = move<int>(& __clang_tmp_3); int *v = move_if_noexcept<int>(& y); struct S s1; S::Ctor(& s1,2); struct S s2; S::Ctor(& s2,1); - _Bool const __clang_tmp_3 = (_Bool)(s1.x >= 0); + _Bool const __clang_tmp_4 = (_Bool)(s1.x >= 0); struct pair<int&,bool> ib; - pair<int&,bool>::Ctor(& ib,& x,& __clang_tmp_3); + pair<int&,bool>::Ctor(& ib,& x,& __clang_tmp_4); { struct pair<int&,bool> *tmp_3; - _Bool __clang_tmp_5 = (_Bool)(s2.x >= 0); + _Bool __clang_tmp_6 = (_Bool)(s2.x >= 0); struct pair<int,bool> __fc_tmp_4 = - make_pair<int&,bool>(& y,& __clang_tmp_5); + make_pair<int&,bool>(& y,& __clang_tmp_6); tmp_3 = operator=<int,bool,void>(& ib,& __fc_tmp_4); pair<int,bool>::Dtor((struct pair<int,bool> const *)(& __fc_tmp_4)); } struct pair<int,double> p; pair<int,double>::Ctor(& p); - int const __clang_tmp_6 = 8; - double const __clang_tmp_7 = 4.0; + int const __clang_tmp_7 = 8; + double const __clang_tmp_8 = 4.0; struct pair<int,double> q; - pair<int,double>::Ctor(& q,& __clang_tmp_6,& __clang_tmp_7); + pair<int,double>::Ctor(& q,& __clang_tmp_7,& __clang_tmp_8); struct pair<int,double> *r = & q; swap<int,double>(& p,r); tmp_4 = get<0,int,double>(& p); diff --git a/tests/stl/stl_utility.cpp b/tests/stl/stl_utility.cpp index 67b6e4a69afd44ed77dd35f1229088363671afcb..b684d1757507fe0977f5a31696def7d02977a3d0 100644 --- a/tests/stl/stl_utility.cpp +++ b/tests/stl/stl_utility.cpp @@ -15,6 +15,7 @@ int f(int x) { std::swap<int,2>(A,B); int && z = std::forward<int>(x); int && t = std::forward<int>(z); + int && xr = std::forward<int>(x + 1); int && u = std::move<int>(42); int && v = std::move_if_noexcept<int>(y); S s1(2);