<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:george.burgess.iv@gmail.com" title="George Burgess <george.burgess.iv@gmail.com>"> <span class="fn">George Burgess</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED WORKSFORME - Should immediately reading from a consumed object provoke a warning?"
   href="https://llvm.org/bugs/show_bug.cgi?id=31234">bug 31234</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>george.burgess.iv@gmail.com
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>WORKSFORME
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED WORKSFORME - Should immediately reading from a consumed object provoke a warning?"
   href="https://llvm.org/bugs/show_bug.cgi?id=31234#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED WORKSFORME - Should immediately reading from a consumed object provoke a warning?"
   href="https://llvm.org/bugs/show_bug.cgi?id=31234">bug 31234</a>
              from <span class="vcard"><a class="email" href="mailto:george.burgess.iv@gmail.com" title="George Burgess <george.burgess.iv@gmail.com>"> <span class="fn">George Burgess</span></a>
</span></b>
        <pre>Thanks for the report! Looks like clang-tidy's misc-use-after-move check
catches things like this, though. :)

$ cat /tmp/tc.cpp
#include <iostream>
#include <utility>
#include <vector>

int main(int, char**) {
  std::string a("hello");
  std::vector<std::string> x;
  x.emplace_back(std::move(a));

  if (a == "hello") {
    std::cout << "a retains original value" << std::endl;
  }

  return 0;
}

$ ./bin/clang-tidy /tmp/tc.cpp -extra-arg=-std=c++11
-checks=misc-use-after-move
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "/tmp/tc.cpp"
No compilation database found in /tmp or any parent directory
json-compilation-database: Error while opening JSON database: No such file or
directory
Running without flags.
1 warning generated.
/tmp/tc.cpp:10:7: warning: 'a' used after it was moved [misc-use-after-move]
  if (a == "hello") {
      ^
/tmp/tc.cpp:8:5: note: move occurred here
  x.emplace_back(std::move(a));
    ^</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>