g++ 4.6.3 gives me this build warning:
parser/html/nsHtml5TreeOperation.cpp: In member function ‘nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**)’:
parser/html/nsHtml5TreeOperation.cpp:276:28: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
...for this code:
> 275 PRUint32 pos = parent->IndexOf(node);
> 276 NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
The assertion there probably wants to compare to nsTArray::NoIndex (which is something like UINT_MAX, IIRC)
This code has been basically the same since this file was added in bug 487949, in 2009, but I think GCC only recently started reporting warnings for this issue.
(In reply to Daniel Holbert [:dholbert] from comment #0)
> The assertion there probably wants to compare to nsTArray::NoIndex (which is
> something like UINT_MAX, IIRC)
> This code has been basically the same since this file was added in bug
> 487949, in 2009, but I think GCC only recently started reporting warnings
> for this issue.
Oh, nevermind -- I was assuming parent was a nsTArray, but it's actually it's a nsIContent*. And I seem to remember nsIContent::IndexOf recently changing to return an unsigned value, so that would make sense as a proximate cause for this warning cropping up.
er, just kidding -- nsINode::IndexOf returns a _signed_ value and always has, AFAICT:
So the real bug here is that |pos| is a PRUint32 when it should be a PRInt32.
Created attachment 613048 [details] [diff] [review]
Comment on attachment 613048 [details] [diff] [review]
Thanks for catching this.
No problem -- thanks for the review!