Closed
Bug 265709
Opened 20 years ago
Closed 20 years ago
suspicious cast in prnetdb on Solaris AMD64
Categories
(NSPR :: NSPR, defect, P3)
Tracking
(Not tracked)
RESOLVED
FIXED
4.5.1
People
(Reporter: julien.pierre, Assigned: julien.pierre)
Details
When building NSPR on Solaris AMD64, I get the following warnings with gcc (but
not with Sun studio) :
../../../../pr/src/misc/prnetdb.c:2131: warning: cast from pointer to integer of
different size
../../../../pr/src/misc/prnetdb.c:2135: warning: cast to pointer from integer of
different size
The assignment on the first warning line is :
PRIntn iter = (PRIntn) iterPtr;
Where iterPtr is an argument declared as void* .
The second warning line is :
return (void *) iter;
PRIntn is typedef'ed to int in prtypes.h, which on this platform is smaller than
the size needed to hold a void* . It would therefore appear that this code is
broken for platforms where sizeof(void*) != sizeof(int), and needs to be changed
to use some other type than PRIntn. Wan-Teh, do you agree ?| Assignee | ||
Updated•20 years ago
|
Priority: -- → P1
Target Milestone: --- → 4.5.1
| Assignee | ||
Updated•20 years ago
|
Assignee: wchang0222 → julien.pierre.bugs
Keywords: sun-orion3
Comment 1•20 years ago
|
||
This code is broken only if the value of 'iter' cannot be stored in a void* pointer without loss. The maximum value 'iter' can assume is the number of IP addresses of the host, which is much smaller than 2^32 or 2^64.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Comment 2•20 years ago
|
||
If you really want to eliminate the warnings, you
can try something like:
PRIntn iter = (PRIntn)(PRPtrdiff) iterPtr;
return (void *)(PRPtrdiff) iter;| Assignee | ||
Comment 3•20 years ago
|
||
Thanks for pointing out that the cast doesn't cause a real problem. Your solution works and eliminates the gcc compiler warning on AMD64. I would still like to see this fixed because the warning is not a benign one, and is likely to waste time the next time we go over the compiler warnings. Please check your solution to the tip. Thanks again !
Keywords: sun-orion3
Updated•20 years ago
|
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Comment 4•20 years ago
|
||
Do you want the warnings fixed on the NSPR_4_5_BRANCH, too?
Status: REOPENED → ASSIGNED
| Assignee | ||
Comment 5•20 years ago
|
||
Sure. Thanks !
| Assignee | ||
Comment 6•20 years ago
|
||
Fixed on NSPR_4_5_BRANCH : Checking in prnetdb.c; /cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c,v <-- prnetdb.c new revision: 3.41.2.1; previous revision: 3.41 Wan-Teh, please check in on the tip and close this bug. Thanks. I'm reducing this bug to P3 / trivial since this has only a compiler warning impact.
Severity: normal → trivial
Priority: P1 → P3
Comment 7•20 years ago
|
||
Fix checked in on the NSPR trunk (NSPR 4.6) and NSPRPUB_PRE_4_2_CLIENT_BRANCH (post Mozilla 1.8 Alpha 4).
Status: ASSIGNED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•