On Tue, Jul 16, 2013 at 12:50 PM, Lubos Lunak <span dir="ltr"><<a href="mailto:l.lunak@suse.cz" target="_blank">l.lunak@suse.cz</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">
<div class="im">On Tuesday 16 of July 2013, Richard Smith wrote:<br>
> On Tue, Jul 16, 2013 at 10:45 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
> > 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>
><br>
> Right. We usually try to stay on the side of no-false-positives, but in<br>
> this case diligent users would find themselves annotating nearly all<br>
> classes, and that doesn't seem like a good tradeoff.<br>
<br>
</div> I'd rather worry about those that won't be dilligent.<br>
<div class="im"><br>
> Also, we identified<br>
> that there are at least three different kinds of class here:<br>
><br>
>  1) Those where the ctor and/or the dtor has external, permanent<br>
> side-effects (probably very rare)<br>
>  2) Those where the ctor or dtor have external, temporary side-effects, but<br>
> running one then the other is essentially equivalent to running neither<br>
> (for instance, many RAII objects follow this pattern)<br>
>  3) Those where the ctor and dtor have no external side-effects<br>
><br>
> Consider:<br>
><br>
> {<br>
>   my_lock(my_mutex); // A<br>
>   my_lock ml(my_mutex); // B<br>
>   my_string("foo"); // C<br>
>   my_string ms("foo"); // D<br>
> }<br>
><br>
> We never warn for a class that is in category (1). my_lock would be in<br>
> category (2), so we warn on A but not B. my_string would be in category<br>
> (3), so we warn on both C and D.<br>
><br>
> Which of these does the warn_unused attribute model?<br>
<br>
</div> It doesn't model anything. It prevents disabling of the unused-variable<br>
warning for whatever type that has the attribute.</blockquote><div><br></div><div>So which of the above behaviors do you get? (Or do you get something else?) </div></div>