[cfe-dev] Incomplete set of warnings in clang
Marshall Clow
mclow.lists at gmail.com
Mon Mar 10 12:35:50 PDT 2014
On Mar 10, 2014, at 12:22 PM, Richard Trieu <rtrieu at google.com> wrote:
> Marshall,
>
> Equality comparisons appear to have their own subset of -Wunused-value in -Wunused-comparison. -Wunused-comparison checks both builtin and overloaded == and !=, which is the two warnings you saw. For the relational operators, -Wunused-value does not check for overloaded operators. So a < comparison of int's would trigger -Wunused-value warnings while a < comparison of iterators would not. This looks like an oversight from when the warning was implemented. I think the fix is to move the relational comparisons into -Wunused-comparison so that relational overloads will also be warned on.
Sounds good to me.
If you don’t want to do this, I will … in about a week.
— Marshall
>
> Richard.
>
>
> On Mon, Mar 10, 2014 at 11:23 AM, Chandler Carruth <chandlerc at google.com> wrote:
> (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/5681761c/attachment.html>
More information about the cfe-dev
mailing list