<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>-llvm-dev</div>
<div><br></div>
<div>Actually, maybe "spurious cast" is too broad and ambitious. Maybe it's better to focus specifically on std::move.</div>
<div><br></div>
<div>The only thing I am really interested in is stuff like</div>
<div><br></div>
<div>class A {</div>
<div>public:</div>
<div>    A &operator=(const A &a) {</div>
<div>        // do some copy ...</div>
<div>        return *this;</div>
<div>    }</div>
<div>}</div>
<div><br></div>
<div>int f() {</div>
<div>    A a;</div>
<div>    A b;</div>
<div>    b = std::move(a);</div>
<div>}</div>
<div><br></div>
<div>, which can be a source of unforeseen performance bugs (e.g., people think they are moving big vectors but really copying them)</div>
<div><br></div>
<div>On Mon, Apr 10, 2017, at 02:39 AM, mats petersson wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div><div>What does "have no effect" mean in this case? In my mind, there are many casts that have no effect - other than allowing the code to compile, which is quite an important effect in itself (e.g. casting a 32-bit unsigned to a pointer on your typical 32-bit system).<br></div>
</div>
<div><div>Are you seeking to warn for:<br></div>
</div>
<div>   int a;<br></div>
<div><div>   int b;<br></div>
</div>
<div><div>   a = (int) b;<br></div>
</div>
<div>and similar things?<br></div>
<div><div><br></div>
<div>--<br></div>
</div>
<div>Mats<br></div>
</div>
<div><div><br></div>
<div defang_data-gmailquote="yes"><div>On 9 April 2017 at 20:35, Craig Topper via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;"><div>This is question is probably better on the clang  cfe-dev list. <br></div>
<div><div><div><div><br></div>
<div defang_data-gmailquote="yes"><div>On Sun, Apr 9, 2017 at 12:01 PM Brennan Vincent via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;"><div>How difficult would it be to add a warning to Clang when the programmer<br></div>
<div> performs a cast that provably has no effect?<br></div>
<div> <br></div>
<div> A particular case I have in mind is someone getting confused and calling<br></div>
<div> std::move on an argument to a copy-constructor for a class that doesn't<br></div>
<div> implement move semantics.<br></div>
<div> <br></div>
<div> I would be grateful if someone either (1) told me why this is<br></div>
<div> difficult/impossible, or (2) gave me some pointers to where I could<br></div>
<div> start trying to implement it...<br></div>
<div> ______________________________<wbr>_________________<br></div>
<div> LLVM Developers mailing list<br></div>
<div> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br></div>
<div> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></div>
</blockquote></div>
</div>
</div>
</div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)"></span></span><br></div>
<div dir="ltr"><span><span class="colour" style="color:rgb(136, 136, 136)">-- </span></span><br></div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)">~Craig</span></span><br></div>
<div><span><span class="colour" style="color:rgb(136, 136, 136)"></span></span><br></div>
<div>______________________________<wbr>_________________<br></div>
<div> LLVM Developers mailing list<br></div>
<div> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br></div>
<div> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></div>
<div> <br></div>
</blockquote></div>
</div>
</blockquote><div><br></div>
</body>
</html>