Patch #3181 2011-07-05 10:56

petschy

Fix for warning -Wint-to-pointer-cast in src/include/prep.h
Download
3181-Fix_for_warnin.patch (1.0 KB)
Category
Platform-Specific
Status
Accepted
Close date
2012-10-12 08:53
Assigned to
mortenmacfly
When compiling on 64bit Debian Wheezy w/ gcc 4.6.1, I get warnings like:

../../../../../src/include/prep.h: In member function ‘ID::operator void*() const’:
../../../../../src/include/prep.h:333:45: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Solved with proper ptr size agnostic cast.

Regards, Peter


# svn diff
Index: src/include/prep.h
===================================================================
--- src/include/prep.h    (revision 7280)
+++ src/include/prep.h    (working copy)
@@ -6,6 +6,8 @@
 #if ( !defined (PREP_H) && defined(__cplusplus) )
 #define PREP_H
 
+#include <stdint.h>
+
 #ifndef wxMAJOR_VERSION
 #include <wx/version.h>
 #endif
@@ -330,7 +332,7 @@
     ID() : value ((unsigned) -1) {};
 
     operator unsigned int() const { return value; };
-    operator void*() const { return (void*) value; };
+    operator void*() const { return reinterpret_cast<void*>(static_cast<uintptr_t>(value)); };
 
     bool Valid() const { return value != ((unsigned) -1); };
     bool operator!() const { return !Valid(); };
mortenmacfly 2012-10-12 08:53

applied modified