Closed Bug 1573501 Opened 5 years ago Closed 5 years ago

media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c:696:19: error: result of comparison 'ulong' (aka 'unsigned long') > 4294967295 is always false [-Werror,-Wtautological-type-limit-compare]

Categories

(Firefox Build System :: Toolchains, defect)

defect
Not set
normal

Tracking

(firefox70 fixed)

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: away, Assigned: away)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The upcoming clang 9 warns about this, which breaks the build due to -Werror.

https://searchfox.org/mozilla-central/rev/30b01f4f60dbcbd6b01500a26b3100c28005cf62/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c#696

    ulong l_val;
...
        if (l_val > 4294967295UL) {

(This only happens on 32-bit builds)

This is actually a more general problem so I'm going to move it into the build system component.

Our code has a pre-existing use of -Wtype-limits: https://searchfox.org/mozilla-central/rev/c7e8bc4996f979e5876b33afae3de3b1ab4f3ae1/build/moz.configure/warnings.configure#59

Apparently clang 8 didn't act on -Wtype-limits. Clang 9 gained support for it in https://reviews.llvm.org/D58841, and the flag enables -Wtautological-type-limit-compare. The latter flag is normally off by default (https://reviews.llvm.org/D41512 talks about exactly this type of "tautological on 32-bit builds but not 64-bit builds" pattern ), but now we're enabling the warning via -Wtype-limits.

I guess we should just disable -Wtautological-type-limit-compare.

Component: WebRTC: Signaling → Toolchains
Product: Core → Firefox Build System

Chris, what do you think?

Flags: needinfo?(cpeterson)

(In reply to :dmajor from comment #2)

Apparently clang 8 didn't act on -Wtype-limits. Clang 9 gained support for it in https://reviews.llvm.org/D58841, and the flag enables -Wtautological-type-limit-compare. The latter flag is normally off by default (https://reviews.llvm.org/D41512 talks about exactly this type of "tautological on 32-bit builds but not 64-bit builds" pattern ), but now we're enabling the warning via -Wtype-limits.

I guess we should just disable -Wtautological-type-limit-compare.

I think disabling -Wtautological-type-limit-compare globally is fine as long as we keep enabling -Wtype-limits for gcc.

clang's diagnostic docs [1] say -Wtype-limits is now a synonym for -Wtautological-constant-in-range-compare, which enables three sub-warnings [2]. We already explicitly enable the zero-compare sub-warnings [3]. The -Wtautological-type-limit-compare sub-warning, however, is annoying for reasonable code like comment 0 that is written defensively to handle various integer ranges.

The correct warning fix would require #ifdefs or macros for different CPU architectures at compile time (since this is C code and can't use C++'s std::numeric_limits templates). That is still an option because webrtc/signaling is first-party Mozilla code (while webrtc/trunk is upstream WebRTC.org code vendored into mozilla-central).

[1] https://clang.llvm.org/docs/DiagnosticsReference.html#wtype-limits
[2] https://github.com/Barro/compiler-warnings/blame/master/clang/warnings-clang-top-level-8.txt#L620-L629
[3] https://searchfox.org/mozilla-central/rev/c7e8bc4996f979e5876b33afae3de3b1ab4f3ae1/build/moz.configure/warnings.configure#110-111

Flags: needinfo?(cpeterson)

This warning, new in clang 9, is noisy about patterns like:

unsigned long x = ...
if (x > 4294967295)

The condition is always false on 32-bit and LLP64 systems, but on LP64 it's a valid test.

Pushed by dmajor@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4b5339bfcdaa
Disable -Wtautological-type-limit-compare r=froydnj
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
Assignee: nobody → dmajor
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: