Closed
Bug 298259
Opened 20 years ago
Closed 20 years ago
cast from 'void*' to 'PRUint32' loses precision while compiling with gcc4 on amd64/x86_64
Categories
(Core :: Networking: HTTP, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 269823
People
(Reporter: bugzilla, Assigned: darin.moz)
Details
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8b2) Gecko/20050620 Firefox/1.0+
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8b2) Gecko/20050620 Firefox/1.0+
This occurs in netwerk/protocol/http/src/nsHttpConnectionMgr.cpp and widget/src/gtk2/nsDragService.cpp.
Reproducible: Always
Steps to Reproduce:
1. checkout HEAD
2. compile with gcc (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)
3. kaboom
Actual Results:
c++ -o nsHttpConnectionMgr.o -c -DMOZILLA_INTERNAL_API -DOSTYPE=\"Linux2.6.11\" -DOSARCH=\"Linux\" -DBUILD_ID=0000000000 -DIMPL_NS_NET -I/usr/src/cvs/mozilla/fox/mozilla/netwerk/protocol/http/src/../../../base/src -I/usr/src/cvs/mozilla/fox/mozilla/xpcom/ds -I../../../../dist/include/xpcom -I../../../../dist/include/string -I../../../../dist/include/pref -I../../../../dist/include/nkcache -I../../../../dist/include/mimetype -I../../../../dist/include/intl -I../../../../dist/include/unicharutil -I../../../../dist/include/caps -I../../../../dist/include/xpconnect -I../../../../dist/include/js -I../../../../dist/include/uconv -I../../../../dist/include/necko -I../../../../dist/include -I../../../../dist/include/nspr -I../../../../dist/sdk/include -I/usr/X11R6/include -fPIC -I/usr/X11R6/include -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic -fshort-wchar -pthread -pipe -DNDEBUG -DTRIMMED -O -I/usr/X11R6/include -DMOZILLA_CLIENT -include ../../../../mozilla-config.h -Wp,-MD,.deps/nsHttpConnectionMgr.pp /usr/src/cvs/mozilla/fox/mozilla/netwerk/protocol/http/src/nsHttpConnectionMgr.cpp
/usr/src/cvs/mozilla/fox/mozilla/netwerk/protocol/http/src/nsHttpConnectionMgr.cpp: In member function 'void nsHttpConnectionMgr::OnMsgUpdateParam(PRInt32, void*)':
/usr/src/cvs/mozilla/fox/mozilla/netwerk/protocol/http/src/nsHttpConnectionMgr.cpp:894: error: cast from 'void*' to 'PRUint32' loses precision
/usr/src/cvs/mozilla/fox/mozilla/netwerk/protocol/http/src/nsHttpConnectionMgr.cpp:895: error: cast from 'void*' to 'PRUint32' loses precision
gmake[6]: *** [nsHttpConnectionMgr.o] Error 1
I was able to force the compile by upcasting the void* to (unsigned long) before it was downcast to PRUint32, but I bet that is the worst possible thing I could have done.
Here is the actual patch, if anyone cares:
--- netwerk/protocol/http/src/nsHttpConnectionMgr.cpp 15 Jan 2005 07:01:20 -0000 1.10
+++ netwerk/protocol/http/src/nsHttpConnectionMgr.cpp 20 Jun 2005 16:48:12 -0000
@@ -891,8 +891,9 @@
void
nsHttpConnectionMgr::OnMsgUpdateParam(PRInt32, void *param)
{
- PRUint16 name = (PRUint32(param) & 0xFFFF0000) >> 16;
- PRUint16 value = PRUint32(param) & 0x0000FFFF;
+ unsigned long bob = (unsigned long)param;
+ PRUint16 name = (PRUint32(bob) & 0xFFFF0000) >> 16;
+ PRUint16 value = PRUint32(bob) & 0x0000FFFF;
switch (name) {
case MAX_CONNECTIONS:
As per the instructions, here is my buildconfig:
x86_64-unknown-linux-gnu
Build tools
Compiler Version Compiler flags
gcc gcc version 4.0.0 20050519 (Red Hat 4.0.0-8) -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -pthread -pipe
c++ gcc version 4.0.0 20050519 (Red Hat 4.0.0-8) -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic -fshort-wchar -pthread -pipe -I/usr/X11R6/include
Configure arguments
--enable-application=browser --with-default-mozilla-five-home=/opt/firefox --with-system-jpeg --with-system-zlib --with-system-png --enable-official-branding --enable-default-toolkit=gtk2 --enable-application=browser --enable-xft --disable-freetype2 --enable-pango --enable-xinerama --with-java-include-path=/usr/j2se --with-java-bin-path=/usr/j2se/bin --disable-installer --disable-tests --disable-static --disable-debug| Assignee | ||
Comment 1•20 years ago
|
||
It turns out that the |void*| parameter in this case is intentionally being used to convey a 32-bit unsigned integer. Better casting is therefore the correct solution.
Comment 2•20 years ago
|
||
*** This bug has been marked as a duplicate of 269823 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•