Closed
Bug 873
Opened 26 years ago
Closed 26 years ago
PR_..printf("%d %lld", LONG_MIN, LONGLONG_MIN) doesn't work
Categories
(NSPR :: NSPR, defect, P2)
Tracking
(Not tracked)
VERIFIED
INVALID
People
(Reporter: rainer, Assigned: wtc)
Details
Subject says it all, more or less. Buggy source file is prprf.c, function dosprintf:
if (u.l < 0) {
u.l = -u.l; /* BUG: overflow if u.l equals LONG_MIN */
flags |= _NEG;
}
Same problem for long longs, a few lines further down.
Th
Assignee | ||
Comment 1•26 years ago
|
||
Thanks for the bug report, and sorry about the delay.
I saw what is wrong in the code. I will send you a
patch soon and let you review and try it out.
Status: NEW → ASSIGNED
Comment 3•26 years ago
|
||
per leger, assigning QA contacts to all open bugs without QA contacts according
to list at http://bugzilla.mozilla.org/describecomponents.cgi?product=Browser
Comment 4•26 years ago
|
||
Need to track in js/src/jsprf.c, adding mccabe@netscape.com to cc: list.
/be
Comment 5•26 years ago
|
||
moving to m6
Updated•26 years ago
|
Target Milestone: M4 → M6
Comment 6•26 years ago
|
||
NSPR now has its own Bugzilla product. Moving this bug to the NSPR product.
Assignee | ||
Updated•26 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → INVALID
Assignee | ||
Comment 7•26 years ago
|
||
I looked at the code more carefully and found
that it is fine. The code in question:
if (u.l < 0) {
u.l = -u.l;
flags |= _NEG;
}
does overflow if u.l is LONG_MIN, but when
u.l is passed to cvt_l, it is always cast
to unsigned long before conversion, i.e.,
at the time of conversion, u.l is always
treated as an unsigned long. So the
overflow when it's treated as a signed
type does not cause any harm.
I suppose it might be clearer to declare
u.l as an unsigned type.
Here is a test program:
********* foo.c ***********
#include "nspr.h"
#include <limits.h>
int main()
{
PR_fprintf(PR_STDOUT, "%ld %lld\n", LONG_MIN, LLONG_MIN);
return 0;
}
******** end foo.c ************
On Solaris 2.6, using the Workshop
4.2 compiler, I get the correct output:
-2147483648 -9223372036854775808
Marked the bug invalid.
Assignee | ||
Updated•25 years ago
|
Target Milestone: M6 → ---
You need to log in
before you can comment on or make changes to this bug.
Description
•