<div dir="ltr">Dear all,<br><div class="gmail_quote"><div dir="ltr"><div>Recently, my team suffered from a bug due to a double bad usage of C++.<br><br></div><div>We have a function returning a reference to an object:<br><br></div><div>    Object& GetObject();<br><br></div><div>Sometimes we use this function like this:<br><br></div><div>    auto obj = GetObject();<br><br></div><div>This triggers a copy of the object, which we really don't mean. The two problems are:<br></div><div>1. Object does not delete the copy constructor, nor does it declare one. We have a policy of never using implicitly-declared constructors, we either use `=delete` or `=default`. Nevertheless we missed this class.<br></div><div>2. A reference is demoted to a rvalue due to the usage of `auto` instead of `auto&`.<br><br></div><div>We would like clang to issue warnings in these two cases. The latter case does not really seem easy to warn about, but the former looks straightforward.<br><br></div><div>Does clang offer such warnings?<br><br></div><div>Thanks<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>Andrea Arteaga <br></div></font></span></div>
</div><br></div>