Closed Bug 1087488 Opened 10 years ago Closed 9 years ago

Omnijar.cpp:62:47: warning: self-comparison always evaluates to true [-Wtautological-compare]

Categories

(Core :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Clang 3.5 gives this build warning:
{
$SRC/xpcom/build/Omnijar.cpp:62:47: warning: self-comparison always evaluates to true [-Wtautological-compare]
}

It includes this (preprocessed) source in the warning output:
      nsDirectoryService::gService->Get(((GRE == mozilla::Omnijar::GRE) ?
                                              ^

This is for this code:
> 26 #define SPROP(Type) ((Type == mozilla::Omnijar::GRE) ? sProp[GRE] : sProp[APP])
[...]
> 62       nsDirectoryService::gService->Get(SPROP(GRE), NS_GET_IID(nsIFile),
> 63                                         getter_AddRefs(greDir));
http://mxr.mozilla.org/mozilla-central/source/xpcom/build/Omnijar.cpp#62

...which was added here, for bug 620931:
http://hg.mozilla.org/mozilla-central/rev/88caff1a09d0#l12.86

glandium, can we restructure this code such that it doesn't end up expanding to a tautological comparison?  (Alternately, we could use #pragmas to disable the warning, in a targeted way, but that'd probably be the messier choice.)
Attached patch strawman fixSplinter Review
Still seeing this in current builds. glandium, how does this look?

(The patch avoids passing the constant values GRE & APP into this macro, so now we'll only be using the macro when we've actually got a variable with an unknown value.)
Attachment #8663184 - Flags: review?(mh+mozilla)
Attachment #8663184 - Flags: review?(mh+mozilla) → review+
Assignee: nobody → dholbert
(side note: looks like I don't get this build warning reliably. I suspect it happens when I'm building with distcc (as I normally do), because the file gets preprocessed before being compiled remotely, or something like that. The compiler is probably friendlier about tautologies-hidden-behind-macros when building 100% locally.)
Yes, building preprocessed files is clearly not helping.
https://hg.mozilla.org/mozilla-central/rev/d944a4e95bc3
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: