<div dir="ltr">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.<div><div><br></div><div>–Arthur</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 21, 2015 at 12:19 PM, Dimitry Andric <span dir="ltr"><<a href="mailto:dimitry@andric.com" target="_blank">dimitry@andric.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dim created this revision.<br>
dim added reviewers: mclow.lists, EricWF, howard.hinnant.<br>
dim added a subscriber: cfe-commits.<br>
<br>
Throughout the libc++ headers, there are a few instances where<br>
_VSTD::move() is used to return a local variable.  Howard commented in<br>
r189039 that these were there "for non-obvious reasons such as to help<br>
things limp along in C++03 language mode".<br>
<br>
However, when compiling these headers with warnings on, and in C++11 or<br>
higher mode (like we do in FreeBSD), they cause the following complaints<br>
about pessimizing moves:<br>
<br>
    In file included from tests.cpp:26:<br>
    In file included from tests.hpp:29:<br>
    /usr/include/c++/v1/map:1368:12: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]<br>
        return _VSTD::move(__h);  // explicitly moved for C++03<br>
               ^<br>
    /usr/include/c++/v1/__config:368:15: note: expanded from macro '_VSTD'<br>
    #define _VSTD std::_LIBCPP_NAMESPACE<br>
                  ^<br>
<br>
Attempt to fix this by adding a _LIBCPP_EXPLICIT_MOVE() macro to<br>
__config, which gets defined to _VSTD::move for pre-C++11, and to<br>
nothing for C++11 and later.<br>
<br>
I am not completely satisfied with the macro name (I also considered<br>
_LIBCPP_COMPAT_MOVE and some other variants), so suggestions are<br>
welcome. :)<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11394&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=KBF1lvzcDIZ278eBazTbsNy5I7cbs2yq96N1STuIPUA&s=F19NUNU0LXwlDy6w2Yyz1b3BBuCbCw5w7G5AFjXZ2OI&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D11394</a><br>
<br>
Files:<br>
  include/__config<br>
  include/__hash_table<br>
  include/__tree<br>
  include/algorithm<br>
  include/ext/hash_map<br>
  include/map<br>
  include/unordered_map<br>
<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>