Closed Bug 791138 Opened 7 years ago Closed 7 years ago

SPSProfiler.cpp:410:73: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Reporting build warning:
{
../../../mozilla/js/src/vm/SPSProfiler.cpp: In member function ‘jsbytecode* js::ProfileEntry::pc() volatile’:
../../../mozilla/js/src/vm/SPSProfiler.cpp:410:73: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
}

The line of code is:
> 410     JS_ASSERT_IF(idx != NullPCIndex, idx >= 0 && idx < script()->length);
https://mxr.mozilla.org/mozilla-central/source/js/src/vm/SPSProfiler.cpp#410

I don't immediately see where idx is declared, but it appears to be signed (since we bother comparing it >= 0), and JSScript::length is unsigned (uint32_t)
  https://mxr.mozilla.org/mozilla-central/source/js/src/jsscript.h#369
...so that last comparison is the source of this warning:
 "idx < script()->length"

We can just cast idx to uint32_t there, since we've already checked that it's non-negative.
I fixed this in bug 791608.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Attachment #661060 - Flags: review?(nicolas.b.pierron)
You need to log in before you can comment on or make changes to this bug.