[cfe-dev] Incomplete set of warnings in clang

Chandler Carruth chandlerc at google.com
Mon Mar 10 11:23:59 PDT 2014


(CC-ing our local warnings expert...)


On Mon, Mar 10, 2014 at 11:13 AM, Marshall Clow <mclow.lists at gmail.com>wrote:

> As I was working on a libc++ issue (
> 2263. Comparing iterators and allocator pointers with different
> const-character), if anyone cares, I wrote the following test program:
>
> #include <string>
>
> int main() {
>   std::string::iterator it;
>   std::string::const_iterator cit;
>
>   it == cit;
>   it != cit;
>   it < cit;
>   it <= cit;
>   it > cit;
>   it >= cit;
> }
>
> I wanted to make sure that these were all legal comparisons using libc++
> (and they are).
> I kind of expected some compiler warnings about “unused results” or
> something.
>
> What I didn’t expect was to get _two_ warnings. I figured either zero or
> some multiple of six.
>
> Apparently clang doesn’t like it if you don’t use the result of == or !=,
> but is perfectly happy with ignoring the results of >, >=, <, <=.
>
> Why is that?
>
> — Marshall
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140310/6c66187f/attachment.html>


More information about the cfe-dev mailing list