title: Binding r-value to l-value reference is non-standard Microsoft C++ extension
body: <p>I've been working on a project recently, and I decided to install ReSharper C++ to Visual Studio. When it analysed my code it spat out a bunch of new warnings (apparently I have bad coding habits..). One of them that took me a while to figure out was <code>Binding r-value to l-value reference is non-standard Microsoft C++ extension</code>. I've recreated the warning with the following code:</p>
  
  <pre><code>Type foo(Type t1, Type t2) {
      return Type(t1.value &amp; t2.value);
  }
  </code></pre>
  
  <p>The expression <code>t1.value &amp; t2.value</code> triggers the warning. I understand the second part of the warning, which means that my code only compiles due to a Microsoft extension, and other compilers would refuse to compile it. I'm using an overloaded operator, which returns an object (called <code>Datum</code>) which <code>Type</code> takes as a constructor parameter, as a reference (<code>Type::Type(Datum&amp; dat)</code>).</p>
  
  <p>With some playing around, I managed to make the warning go away by refactoring the code:</p>
  
  <pre><code>Type bar(Type t1, Type t2) {
      Datum datum = t1.value &amp; t2.value;
      return Type(datum);
  }
  </code></pre>
  
  <p>To my understanding, this is functionally equivalent to the code that generated the warning. What I'd really like to know is whether there's something here that I should be aware of, because I'm pretty confused about why one function complains and one doesn't.</p>
  
  <p><em>I think I've got it figured out. I already had the question typed out, so I'm going to post it with what I found, for the reference of others. I don't really have enough knowledge to go into detail, so please feel free to expand on or correct my answer if it isn't satisfactory :)</em></p>