Closed Bug 803695 Opened 12 years ago Closed 12 years ago

TestCOMPtrEq.cpp:78:18: warning: self-comparison always evaluates to true [-Wtautological-compare]

Categories

(Core :: XPCOM, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I tried setting FAIL_ON_WARNINGS in /xpcom/tests, and it's fine on Linux w/ GCC, but on Mac we trigger these:
{

../../../../xpcom/tests/TestCOMPtrEq.cpp:78:18: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
              (r == r) &&
                 ^
../../../../xpcom/tests/TestCOMPtrEq.cpp:94:19: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
              (rc == rc) &&
                  ^
../../../../xpcom/tests/TestCOMPtrEq.cpp:102:19: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
              (rk == rk) &&
                  ^
../../../../xpcom/tests/TestCOMPtrEq.cpp:110:20: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
              (rkc == rkc) &&
                   ^
../../../../xpcom/tests/TestCOMPtrEq.cpp:118:18: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
              (d == d) &&
                 ^
}
https://tbpl.mozilla.org/php/getParsedLog.php?id=16275787&tree=Try

The variables that it's complaining about are all _pointers_ (not objects), so we aren't exercising any fancy operator== behavior.  Here's a snippet from MXR, demonstrating that:
> 52     nsICOMPtrEqTestFoo* r = 0;
[...]
> 54     const nsICOMPtrEqTestFoo* rc = 0;
> 55     nsICOMPtrEqTestFoo* const rk = 0;
> 56     const nsICOMPtrEqTestFoo* const rkc = 0;
> 57     nsICOMPtrEqTestFoo* d = s;
http://mxr.mozilla.org/mozilla-central/source/xpcom/tests/TestCOMPtrEq.cpp

So, I propose we just remove these self-comparisons.
Looks like dbaron wrote this test back in 2001 (in https://bugzilla.mozilla.org/show_bug.cgi?id=65664#c12 ), so requesting r?dbaron.
Attachment #673446 - Flags: review?(dbaron)
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Comment on attachment 673446 [details] [diff] [review]
fix & mark directory as warning-free

r=dbaron
Attachment #673446 - Flags: review?(dbaron) → review+
Depends on: 65664
OS: Linux → Mac OS X
Hardware: x86_64 → All
Summary: TestCOMPtrEq.cpp:78:18: warning: self-comparison always evaluates to true [-Werror,-Wtautological-compare] → TestCOMPtrEq.cpp:78:18: warning: self-comparison always evaluates to true [-Wtautological-compare]
https://hg.mozilla.org/mozilla-central/rev/4ae3fd8d62f4
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Depends on: 804872
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: