[llvm-dev] [cfe-dev] New warnings when building trunk with GCC 9 (original) (raw)
James Dennett via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 26 04:38:20 PDT 2018
- Previous message: [llvm-dev] [cfe-dev] New warnings when building trunk with GCC 9
- Next message: [llvm-dev] [cfe-dev] New warnings when building trunk with GCC 9
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 25, 2018 at 5:08 AM Richard Smith via cfe-dev < cfe-dev at lists.llvm.org> wrote:
On Mon, 24 Sep 2018, 20:40 Richard Trieu via cfe-dev, <_ _cfe-dev at lists.llvm.org> wrote:
+ Erik, who implemented DR1579
Originally, I had the warning similar to GCC's warning, but took it out due to not having DR1579 implemented in clang (warning changed in r243594) Erik in r274291 implemented DR1579, although PR27785 didn't mention anything about std::move It looks like what's happening is that Clang and GCC handles the return differently. Clang needs the std::move call to use the move constructor while GCC will use the move constructor with or without the std::move call. This means that the warning is currently correct when running on either compiler. This is a reduced example. Compiled with Clang, it will print "move constructor" then "copy constructor". GCC will print "move constructor" twice. GCC gets the rule "wrong". The rule in question ( http://eel.is/c++draft/class.copy.elision#3.sentence-2) only applies when the selected B constructor takes A&& as its parameter type. But the rule gets the rule wrong too -- EWG wants that condition removed, so that it's never necessary to write return std::move(local_var);
I think the rule was written as it is to avoid breaking (obscure) working code, but before we had sufficient experience with rvalue references to understand how reasonable it is to pass by value in such cases. The time has come to simplify it.
I have a patch in progress, but lacked the time to finish updating test cases etc. (And I'm on vacation right now.)
-- James -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180926/48ea4e62/attachment.html>
- Previous message: [llvm-dev] [cfe-dev] New warnings when building trunk with GCC 9
- Next message: [llvm-dev] [cfe-dev] New warnings when building trunk with GCC 9
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]