Bug 427146

Summary: valgrind.h: 64bit mingw: cast from pointer to integer of different size
Product: [Developer tools] valgrind Reporter: Christoph Reiter <reiter.christoph>
Component: generalAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Christoph Reiter 2020-09-30 11:31:40 UTC
This is in glib, but I've copied over the valgrind.h from git master and the same warning occurs.

It looks like the code assumes that a pointer can fit into "unsigned long int", but on 64 bit Windows that's not the case. My guess would be that it should use "uintptr_t" instead.

../gobject/gtype.c: In function 'g_type_create_instance':
../gobject/../glib/valgrind.h:417:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  417 |     _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
      |                    ^
../gobject/../glib/valgrind.h:203:15: note: in expansion of macro 'VALGRIND_DO_CLIENT_REQUEST_EXPR'
  203 |   do { (void) VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                        \
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../gobject/../glib/valgrind.h:6479:5: note: in expansion of macro 'VALGRIND_DO_CLIENT_REQUEST_STMT'
 6479 |     VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MALLOCLIKE_BLOCK,       \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../gobject/gtype.c:1844:7: note: in expansion of macro 'VALGRIND_MALLOCLIKE_BLOCK'
 1844 |       VALGRIND_MALLOCLIKE_BLOCK (allocated + private_size, ivar_size + sizeof (gpointer), 0, TRUE);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~
../gobject/../glib/valgrind.h:417:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  417 |     _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
      |                    ^
../gobject/../glib/valgrind.h:203:15: note: in expansion of macro 'VALGRIND_DO_CLIENT_REQUEST_EXPR'
  203 |   do { (void) VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                        \