<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On May 15, 2018, at 6:05 PM, George Karpenkov via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">+cfe-dev<div class=""><br class=""></div><div class="">Hi Andrea,</div><div class=""><br class=""></div><div class="">I think you might get more luck asking on the cfe-dev mailing list.</div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">George</div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On May 15, 2018, at 1:15 PM, Andrea Arteaga via cfe-users <<a href="mailto:cfe-users@lists.llvm.org" class="">cfe-users@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Dear all,<br class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="">Recently, my team suffered from a bug due to a double bad usage of C++.<br class=""><br class=""></div><div class="">We have a function returning a reference to an object:<br class=""><br class=""></div><div class=""> Object& GetObject();<br class=""><br class=""></div><div class="">Sometimes we use this function like this:<br class=""><br class=""></div><div class=""> auto obj = GetObject();<br class=""><br class=""></div><div class="">This triggers a copy of the object, which we really don't mean. The two problems are:<br class=""></div><div class="">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 class=""></div></div></div></div></div></blockquote></div></div></div></div></blockquote><div><br class=""></div>Implicitly-defined copy constructors are ubiquitous in idiomatic C++. Maybe that's not true in your project, but still, this seems too special-case for the compiler. Maybe a linter that has a more sophisticated model of what code is yours vs. the standard library.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class=""><div class="">2. A reference is demoted to a rvalue due to the usage of `auto` instead of `auto&`.<br class=""></div></div></div></div></div></blockquote></div></div></div></div></blockquote><div><br class=""></div></div>This is a more reasonable thing to try to warn about. I have two concerns:<div class=""> - I don't know a reasonable way to suppress the warning if you really do want to load from the l-value.</div><div class=""><div class=""><div class=""> - I have a non-specific worry that it'll disrupt some important idiom that I'm just not thinking of.</div></div><div class="">But those are concerns that we could explore during iterative design and implementation.</div><div class=""><div class=""><br class=""></div><div class="">John.</div></div></div></body></html>