Closed
Bug 265368
Opened 20 years ago
Closed 8 years ago
LL_INIT warning: signed shift result (0x8000000000000000) sets the sign bit of the shift expression's type ('long long') and becomes negative [-Wshift-sign-overflow]
Categories
(NSPR :: NSPR, defect)
Tracking
(firefox46 affected)
RESOLVED
FIXED
4.13
Tracking | Status | |
---|---|---|
firefox46 | --- | affected |
People
(Reporter: julien.pierre, Assigned: wtc)
References
(Blocks 1 open bug)
Details
(Whiteboard: [build_warning])
Attachments
(2 files)
1.69 KB,
patch
|
Details | Diff | Splinter Review | |
805 bytes,
patch
|
ted
:
superreview+
wtc
:
checked-in+
|
Details | Diff | Splinter Review |
The following warnings occur on all Solaris platforms (sparc32/sparc64/x86/AMD64) : "../../../../pr/src/misc/prlong.c", line 39: warning: integer overflow detected: op "<<" "../../../../pr/src/misc/prlong.c", line 40: warning: integer overflow detected: op "<<" "../../../../pr/src/misc/prlong.c", line 40: warning: initializer does not fit or is out of range: -1 Lines 39 and 40 are respectively . static PRInt64 ll_minint = LL_INIT( 0x80000000, 0x00000000 ); static PRUint64 ll_maxuint = LL_INIT( 0xffffffff, 0xffffffff ); The warnings occur only when trying to set the highest bit . I don't think they denote an actual problem with the code, but it would be nice to be able to come up with a definition for LL_INIT that works and doesn't generate warnings. I believe it may be possible to eliminate the first warning through clever use of casting inside the LL_INIT macro definition. As for eliminating the second warning, it may require a separate ULL_INIT macro ...
Updated•20 years ago
|
OS: SunOS → Solaris
Updated•18 years ago
|
QA Contact: wtchang → nspr
Updated•13 years ago
|
Blocks: buildwarning
Whiteboard: [build_warning]
Comment 1•8 years ago
|
||
Julien, do you still see these LL_INIT warnings with the Sun compiler? I can reproduce these warnings with clang on OS X if I enable clang's off-by-default -Wshift-sign-overflow warning: warning: signed shift result (0x8000000000000000) sets the sign bit of the shift expression's type ('long long') and becomes negative [-Wshift-sign-overflow] warning: signed shift result (0xFFFFFFFF00000000) sets the sign bit of the shift expression's type ('long long') and becomes negative [-Wshift-sign-overflow] Fixing this warning is a very low priority because clang -Wshift-sign-overflow is disabled by default and LL_INIT is only used in a few places in NSPR and NSS: https://mxr.mozilla.org/mozilla-central/ident?i=LL_INIT
status-firefox46:
--- → affected
Flags: needinfo?(julien.pierre)
Summary: compiler warnings related to LL_INIT → LL_INIT warning: signed shift result (0x8000000000000000) sets the sign bit of the shift expression's type ('long long') and becomes negative [-Wshift-sign-overflow]
Assignee | ||
Comment 2•8 years ago
|
||
Chris: thank you very much for looking at this bug and suggesting an easy way to reproduce the compiler warning. This bug was rediscovered recently in bug 1180095. I attached a patch, which shows the fix may break some workarounds for this bug and therefore require undoing the workarounds. So I'm not sure if we should fix this bug. The best workaround available today to replace LL_INIT() with PR_INT64() or PR_UINT64().
Assignee | ||
Comment 3•8 years ago
|
||
Attachment #8701223 -
Flags: superreview?(ted)
Attachment #8701223 -
Flags: review?(kaie)
Comment 4•8 years ago
|
||
Comment on attachment 8701223 [details] [diff] [review] Use PR_INT64() or PR_UINT64() instead of LL_INIT() Review of attachment 8701223 [details] [diff] [review]: ----------------------------------------------------------------- This seems fine. I can't imagine we actually build anywhere that doesn't support 64-bit integer literals.
Attachment #8701223 -
Flags: superreview?(ted)
Attachment #8701223 -
Flags: superreview+
Attachment #8701223 -
Flags: review?(kaie)
Reporter | ||
Updated•8 years ago
|
Flags: needinfo?(julien.pierre)
Comment 5•8 years ago
|
||
(In reply to Wan-Teh Chang from comment #2) > > I attached a patch, which shows the fix may break some > workarounds for this bug and therefore require undoing the workarounds. Which specific workarounds might this patch break? Since this patch changes how these 4 constants are being defined, but doesn't change any macros, I don't understand how this could affect any other code. Which workarounds do you think would have to be undone? And if there is anything that needs to be undone - shouldn't this patch be combined with a patch that includes the undos that you are referring to, to ensure everything gets landed at the same time?
Comment 6•8 years ago
|
||
To, me the patch looks fine, too. Unless we get an explanation, I'd suggest to land this soon. (However, we should postpone 1-2 weeks, because NSPR is frozen for release preparations currently.)
Keywords: checkin-needed
Updated•8 years ago
|
Target Milestone: --- → 4.13
Comment 9•8 years ago
|
||
Finally I saw this again, and checked it in. https://hg.mozilla.org/projects/nspr/rev/d3820777dd94
Updated•8 years ago
|
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 10•8 years ago
|
||
Comment on attachment 8701223 [details] [diff] [review] Use PR_INT64() or PR_UINT64() instead of LL_INIT() Review of attachment 8701223 [details] [diff] [review]: ----------------------------------------------------------------- Ryan: I'm very sorry I didn't respond. Kai: thank you very much for checking in this patch.
Attachment #8701223 -
Flags: checked-in+
You need to log in
before you can comment on or make changes to this bug.
Description
•