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

RESOLVED FIXED in Firefox 44

Status

()

Core
General
RESOLVED FIXED
3 years ago
2 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
mozilla44
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox44 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
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.)
(Assignee)

Comment 1

2 years ago
Created attachment 8663184 [details] [diff] [review]
strawman fix

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+

Comment 2

2 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/d944a4e95bc3
(Assignee)

Updated

2 years ago
Assignee: nobody → dholbert
(Assignee)

Comment 3

2 years ago
(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
Last Resolved: 2 years ago
status-firefox44: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.