Problem 1720

Summary: compile error: cast from 'PSTR {aka char*}' to 'DWORD {aka long unsigned int }' loses precision
Product: Geant4 Reporter: Mojca Miklavec <mojca.miklavec.lists>
Component: cmakeAssignee: Ben Morgan <Ben.Morgan>
Status: CLOSED WONTFIX    
Severity: trivial    
Priority: P5    
Version: 10.0   
Hardware: PC   
OS: Windows   

Description Mojca Miklavec 2015-03-12 19:02:06 CET
I tried to compile Geant4.10.0.p04 with mingw-w64 (x86_64-4.9.2-posix-seh-rt_v3-rev1) on Windows 7. I generated the makefiles for MinGW with cmake-gui. But the compilation breaks with:

[  3%] Building CXX object CMakeFiles/genwindef.dir/cmake/Modules/genwindef/LibSymbolInfo.cpp.obj
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp: In member function 'BOOL CLibSymbolInfo::Dump(LPTSTR, std::ostream&)':
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:18:59: error: cast from 'PSTR {aka char*}' to 'DWORD {aka long unsigned int
}' loses precision [-fpermissive]
 #define MakePtr( cast, ptr, addValue ) (cast)( (DWORD)(ptr) + (DWORD)(addValue))
                                                           ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:92:13: note: in expansion of macro 'MakePtr'
   pMbrHdr = MakePtr( PIMAGE_ARCHIVE_MEMBER_HEADER, pArchiveStartString,
             ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:18:80: warning: cast to pointer from integer of different size [-Wint-to-po
inter-cast]
 #define MakePtr( cast, ptr, addValue ) (cast)( (DWORD)(ptr) + (DWORD)(addValue))
                                                                                ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:92:13: note: in expansion of macro 'MakePtr'
   pMbrHdr = MakePtr( PIMAGE_ARCHIVE_MEMBER_HEADER, pArchiveStartString,
             ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:18:59: error: cast from 'PDWORD {aka long unsigned int*}' to 'DWORD {aka lo
ng unsigned int}' loses precision [-fpermissive]
 #define MakePtr( cast, ptr, addValue ) (cast)( (DWORD)(ptr) + (DWORD)(addValue))
                                                           ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:108:24: note: in expansion of macro 'MakePtr'
   PSTR pszSymbolName = MakePtr( PSTR, pMemberOffsets, 4 * cSymbols );
                        ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:18:80: warning: cast to pointer from integer of different size [-Wint-to-po
inter-cast]
 #define MakePtr( cast, ptr, addValue ) (cast)( (DWORD)(ptr) + (DWORD)(addValue))
                                                                                ^
C:\app\geant4.10.00.p04\cmake\Modules\genwindef\LibSymbolInfo.cpp:108:24: note: in expansion of macro 'MakePtr'
   PSTR pszSymbolName = MakePtr( PSTR, pMemberOffsets, 4 * cSymbols );
                        ^
CMakeFiles\genwindef.dir\build.make:76: recipe for target 'CMakeFiles/genwindef.dir/cmake/Modules/genwindef/LibSymbolInfo.cpp.obj' failed
mingw32-make[2]: *** [CMakeFiles/genwindef.dir/cmake/Modules/genwindef/LibSymbolInfo.cpp.obj] Error 1
CMakeFiles\Makefile2:409: recipe for target 'CMakeFiles/genwindef.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/genwindef.dir/all] Error 2
makefile:135: recipe for target 'all' failed
mingw32-make: *** [all] Error 2


I will try if I will have more luck with i686.
Comment 1 Ben Morgan 2015-03-17 11:26:11 CET
MinGW isn't a supported platform, and we don't currently have the resource to add it to the testing system - hence the WONTFIX.

However, if you're able to supply a patch then we'll certainly look at incorporating this, even if we're unable to test.
Comment 2 Mojca Miklavec 2015-03-17 11:33:40 CET
I would gladly investigate further, but I need at least some rough pointers.

I know some C++, but I don't understand this pointer casting. i686 compiled successfully after I made some trivial patches. With x86_64 I'm stuck.