sidney added a comment.

In http://reviews.llvm.org/D17043#348525, @alexfh wrote:

> I'd like to note that there is a library-side way to mitigate this issue 
> using the `[[clang::warn_unused_result]]` attribute on `vector::empty()` and 
> similar methods:


Using an attribute sounds much better than this kind of check and I'd be fine 
with throwing this patch out completely. IMHO the diagnostic is bad, though. A 
message like this:

>   q.cc:17:3: warning: ignoring return value of function declared with 
> warn_unused_result attribute [-Wunused-result]

>     v.empty();

>     ^~~~~~~

> 


…is way too literal. It could indicate two completely different issues:

1. `empty()` just tells you whether the container is empty.
2. `empty()` has side effects and returns a value which should never be ignored 
(like recv, send, and scanf).

Searching for this warning (https://www.google.com/search?q="Wunused-result";) 
turns up tons of confusion.

I'm not an expert on attributes. Is there a way to attach metadata (like a 
subtype, or a string description), so that calls without side effects could 
have a diagnostic more like the one I wrote, and things like `recv(2)` and 
`scanf(3)` could have rich messages?

I'm going to hold of on addressing any of your other comments until I hear 
back. Thanks for the review!


http://reviews.llvm.org/D17043



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to