Closed Bug 569586 Opened 10 years ago Closed 10 years ago
XPCOM compilation failure on mingw-w64 due to pointer to int cast loosing precision
I get following errors: xpcom/base/nsStackWalk.cpp:1034:29: error: cast from 'void*' to 'DWORD' loses precision xpcom/ds/nsWindowsRegKey.cpp:142:40: error: cast from 'HKEY__*' to 'PRUint32' loses precision xpcom/ds/nsWindowsRegKey.cpp:160:42: error: cast from 'HKEY__*' to 'PRUint32' loses precision All of those casts are intentional, so proper casts are all we need. The attached patch fixes the problem.
Thanks for quick review.
Sorry, I believe the nsWindowsRegKey changes are incorrect, because nsWindowsRegKey::Open  takes a PRUint32, since it's an IDL method taking an unsigned long . An HKEY is pointer-sized, so the current patch would truncate the handle. I have an old patch  that works, but I'm not quite comfortable with changing the interface - I think it's doable to make the current open() implementation internal and (on win64 at last) add a stub for the predefined HKEYs, but haven't had time to really do it yet :(  http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsWindowsRegKey.cpp?rev=5b3604a3cfbe&mark=109-109#107  http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsIWindowsRegKey.idl?rev=5b3604a3cfbe&mark=141-141#124  http://bitbucket.org/mook/mozwin64/src/tip/win64.nsIWindowsRegKey
My patch doesn't really change anything. These casts are already in the code, all my patch does is a different way of casting that is acceptable for mingw-w64. There even is a comment about the problem: * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey * parameter of this function. However, for compatibility with 64-bit * Windows, that usage should probably be avoided in favor of openChild. And the comment is also quite not right. HKEY is in fact a system HANDLE and such handles, although have 8-bytes size, use only 4 bytes values. so there is no problem with the code (except ugly casts).
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.