Closed Bug 458728 Opened 13 years ago Closed 9 years ago
gcc warning: src/ns
Attr And Child Array .cpp:169: warning: comparison is always true due to limited range of data type
+++ This bug was initially created as a clone of Bug #458491 +++
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
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
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.
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
Closed: 9 years ago
Resolution: --- → INVALID
Attachment #620444 - Flags: review?(bzbarsky) → review-
You need to log in before you can comment on or make changes to this bug.