On Tue, Jul 16, 2013 at 10:45 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I know we'd previously discussed the idea of being able to warn about<br>
unused variables of non-trivial types - you'd gone so far as to<br>
suggest the idea of a positive attribute (annotate the classes that<br>
have side effects, rather than those that don't, since the former<br>
seems like the exception rather than the rule).<br></blockquote><div><br></div><div>Right. We usually try to stay on the side of no-false-positives, but in this case diligent users would find themselves annotating nearly all classes, and that doesn't seem like a good tradeoff. Also, we identified that there are at least three different kinds of class here:</div>
<div><br></div><div> 1) Those where the ctor and/or the dtor has external, permanent side-effects (probably very rare)</div><div> 2) Those where the ctor or dtor have external, temporary side-effects, but running one then the other is essentially equivalent to running neither (for instance, many RAII objects follow this pattern)</div>
<div> 3) Those where the ctor and dtor have no external side-effects</div><div><br></div><div>Consider:</div><div><br></div><div>{</div><div>  my_lock(my_mutex); // A</div><div>  my_lock ml(my_mutex); // B</div><div>  my_string("foo"); // C</div>
<div>  my_string ms("foo"); // D<br>}</div><div><br></div><div>We never warn for a class that is in category (1). my_lock would be in category (2), so we warn on A but not B. my_string would be in category (3), so we warn on both C and D.</div>
<div><br></div><div>Which of these does the warn_unused attribute model?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't suppose that is sufficiently related to this to warrant any<br>

changes here (we probably want to support this the way GCC does for<br>
compatibility at least, even if we come up with a more advanced scheme<br>
(positive annotations & describing the difference between a full-side<br>
effect (such as printing call start/end) and scope (like locks -<br>
warning when there's no code between construction and destruction))).</blockquote><div><br></div><div>Yeah, if GCC's warning proves valuable, we might want to implement it warts-and-all (to assist people using both compilers), even if we also want to add something better.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
On Tue, Jul 16, 2013 at 5:20 AM, Rafael Espíndola<br>
<<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
> LGTM.<br>
><br>
> On 16 July 2013 02:55, Lubos Lunak <<a href="mailto:l.lunak@suse.cz">l.lunak@suse.cz</a>> wrote:<br>
>><br>
>>  Hello,<br>
>><br>
>>  could somebody please review the attached patch for PR14253?<br>
>><br>
>>  The equivalent GCC patch has been accepted (GCC bug #55203) and libstdc++<br>
>> should use the attribute whenever I or somebody write the patch for it.<br>
>> Presumably this Clang patch should be followed by a patch for libc++ (I do<br>
>> not intend to do that).<br>
>><br>
>> --<br>
>>  Lubos Lunak<br>
>>  <a href="mailto:l.lunak@suse.cz">l.lunak@suse.cz</a><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br>