On Wed, Feb 10, 2016 at 5:05 PM, Joerg Sonnenberger via cfe-commits <cfe-commits@lists.llvm.org> wrote: > On Wed, Feb 10, 2016 at 04:21:02PM +0000, Alexander Kornienko via cfe-commits > wrote: >> alexfh added a comment. >> >> Thank you for working on this check! >> >> 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: > > I'm not a big fan of this. Those calls are by the very definition > harmless, so they aggrevate the existing problem of stupid annotation. > The original intention of this attribute was to flag cases of side > effects where ignoring the the result is a definite bug. Consider > calling malloc or realloc and throwing away the result -- that never > makes sense. Then GNU came along and starting to annotate various libc > functions including most of the stdio family. Guess what, standard > streams have a (sticky) error flag, exactly so that you don't have check > every single call. Congratulation, people are just starting to ignore > the warnings now. Fast forward and we have this suggestion...
I'm not sure what point you're making here. A call to vector::empty() that discards the result is always a bug; usually, the intent was to call vector::clear() instead, and the problem isn't just pointless code. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits