-
Notifications
You must be signed in to change notification settings - Fork 682
Description
In this line of code:
Line 96 in be59f3c
| fprintf (stderr, "(%0*lx) ", (unsigned int) (2 * sizeof (void *)), (unsigned long) obj); |
(which was recently copied from src/hb-private.hh) we have this:
fprintf (stderr, "(%0*lx) ", (unsigned int) (2 * sizeof (void *)), (unsigned long) obj);
This code casts a pointer to unsigned long. However the assumption that sizeof(unsigned long) == sizeof(void*) is unjustified. On the Windows platform when compiling for 64-bits (whether compiling with VC++ or with clang-cl) the size of unsigned long is always 32 bits. That is, even in 64-bit builds an unsigned long is 32 bits.
A couple of fixes are available. Using unsigned long long is more portable - casting to a 64-bit type in 32-bit builds is not so terrible. Or, using %z as a size modifier and using size_t as the integer type will also work - %z has been supported on Windows since VC++ 2015.
This code triggers warnings in the latest preview builds of VC++ 2017 when compiling with /permissive- which is a switch that aggressively looks for non-portable code.