gcc warning: src/nsAttrAndChildArray.cpp:169: warning: comparison is always true due to limited range of data type

RESOLVED FIXED

Status

()

Core
Rewriting and Analysis
RESOLVED FIXED
9 years ago
5 years ago

People

(Reporter: georgi - hopefully not receiving bugspam, Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
x86
All
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [build_warning])

Attachments

(1 attachment)

+++ This bug was initially created as a clone of Bug #458491 +++

Updated

6 years ago
Whiteboard: [build_warning]

Updated

6 years ago
Blocks: 458491
No longer depends on: 458491

Comment 1

6 years ago
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsAttrAndChildArray.cpp#169

167   PRUint32 childCount = ChildCount();
168 
169   NS_ENSURE_TRUE(childCount < ATTRCHILD_ARRAY_MAX_CHILD_COUNT,
170                  NS_ERROR_FAILURE);
Summary: gcc warning: src/nsAttrAndChildArray.cpp:167: warning: comparison is always true due to limited range of data type → gcc warning: src/nsAttrAndChildArray.cpp:169: warning: comparison is always true due to limited range of data type

Comment 2

6 years ago
For future reference...

ChildCount() is defined here:
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsAttrAndChildArray.h#83

ATTRCHILD_ARRAY_MAX_CHILD_COUNT here:
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsAttrAndChildArray.h#66

Updated

6 years ago
Blocks: 187528

Comment 3

6 years ago
Is this a valid problem?
Maybe today the comparison is unneeded with the current value of ATTRCHILD_ARRAY_MAX_CHILD_COUNT. But if that constant changes, it may be necessary to catch it here.
Created attachment 620444 [details] [diff] [review]
Patch
Attachment #620444 - Flags: review?(bmo)

Comment 5

5 years ago
Comment on attachment 620444 [details] [diff] [review]
Patch

Sorry, I'm not a peer; redirecting to someone who is :-)
Attachment #620444 - Flags: review?(bmo) → review?(bzbarsky)
Why is this warning at all?  childCount is a PRUint32.  ATTRCHILD_ARRAY_MAX_CHILD_COUNT should be 0x3fffff.  There are certainly values of PRUint32 that are bigger than that!

Marco, I assume you reproduced the warning?
Note that back when the bug was filed, a 64-bit build would have warned here.  But that should have been fixed in bug 480655.
(In reply to Boris Zbarsky (:bz) from comment #6)
> Marco, I assume you reproduced the warning?

No, I just assumed it was reproducible. I didn't see the bug was so old.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → INVALID
Depends on: 480655
Resolution: INVALID → FIXED
Attachment #620444 - Flags: review?(bzbarsky) → review-
You need to log in before you can comment on or make changes to this bug.