>From the peanut gallery: Could someone explain why this warning is actually a false positive in C++03 mode? It seems to me that the std::move there disables NRVO in C++03 to exactly the same degree as it disables NRVO in C++11. Admittedly I have no idea what _VSTD::move(x) does to x in C++03 mode; I'd have expected it to be a no-op, except for disabling RVO.
–Arthur On Tue, Jul 21, 2015 at 12:19 PM, Dimitry Andric <dimi...@andric.com> wrote: > dim created this revision. > dim added reviewers: mclow.lists, EricWF, howard.hinnant. > dim added a subscriber: cfe-commits. > > Throughout the libc++ headers, there are a few instances where > _VSTD::move() is used to return a local variable. Howard commented in > r189039 that these were there "for non-obvious reasons such as to help > things limp along in C++03 language mode". > > However, when compiling these headers with warnings on, and in C++11 or > higher mode (like we do in FreeBSD), they cause the following complaints > about pessimizing moves: > > In file included from tests.cpp:26: > In file included from tests.hpp:29: > /usr/include/c++/v1/map:1368:12: error: moving a local object in a > return statement prevents copy elision [-Werror,-Wpessimizing-move] > return _VSTD::move(__h); // explicitly moved for C++03 > ^ > /usr/include/c++/v1/__config:368:15: note: expanded from macro '_VSTD' > #define _VSTD std::_LIBCPP_NAMESPACE > ^ > > Attempt to fix this by adding a _LIBCPP_EXPLICIT_MOVE() macro to > __config, which gets defined to _VSTD::move for pre-C++11, and to > nothing for C++11 and later. > > I am not completely satisfied with the macro name (I also considered > _LIBCPP_COMPAT_MOVE and some other variants), so suggestions are > welcome. :) > > http://reviews.llvm.org/D11394 > > Files: > include/__config > include/__hash_table > include/__tree > include/algorithm > include/ext/hash_map > include/map > include/unordered_map > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits