Last Comment Bug 458728 - gcc warning: src/nsAttrAndChildArray.cpp:169: warning: comparison is always true due to limited range of data type
: gcc warning: src/nsAttrAndChildArray.cpp:169: warning: comparison is always t...
Status: RESOLVED FIXED
[build_warning]
:
Product: Core
Classification: Components
Component: Rewriting and Analysis (show other bugs)
: Trunk
: x86 All
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on: 480655
Blocks: buildwarning 458491
  Show dependency treegraph
 
Reported: 2008-10-06 07:43 PDT by georgi - hopefully not receiving bugspam
Modified: 2012-05-02 13:46 PDT (History)
8 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (1.14 KB, patch)
2012-05-02 13:07 PDT, Marco Castelluccio [:marco]
bzbarsky: review-
Details | Diff | Review

Description georgi - hopefully not receiving bugspam 2008-10-06 07:43:20 PDT
+++ This bug was initially created as a clone of Bug #458491 +++
Comment 1 Ed Morley [:emorley] 2011-07-08 07:09:23 PDT
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);
Comment 2 Ed Morley [:emorley] 2011-07-08 07:20:41 PDT
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
Comment 3 :aceman 2011-12-12 02:55:11 PST
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 4 Marco Castelluccio [:marco] 2012-05-02 13:07:43 PDT
Created attachment 620444 [details] [diff] [review]
Patch
Comment 5 Ed Morley [:emorley] 2012-05-02 13:12:33 PDT
Comment on attachment 620444 [details] [diff] [review]
Patch

Sorry, I'm not a peer; redirecting to someone who is :-)
Comment 6 Boris Zbarsky [:bz] 2012-05-02 13:22:10 PDT
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?
Comment 7 Boris Zbarsky [:bz] 2012-05-02 13:23:43 PDT
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.
Comment 8 Marco Castelluccio [:marco] 2012-05-02 13:38:30 PDT
(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.

Note You need to log in before you can comment on or make changes to this bug.