diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c index eb90682c2..609697509 100644 --- a/contrib/libtests/pngstest.c +++ b/contrib/libtests/pngstest.c @@ -54,8 +54,11 @@ /* The following is to support direct compilation of this file as C++ */ #ifdef __cplusplus # define voidcast(type, value) static_cast(value) +# define aligncastconst(type, value) \ + static_cast(static_cast(value)) #else # define voidcast(type, value) (value) +# define aligncastconst(type, value) ((const void*)(value)) #endif /* __cplusplus */ /* Generate random bytes. This uses a boring repeatable algorithm and it @@ -2928,8 +2931,8 @@ compare_two_images(Image *a, Image *b, int via_linear, */ if (formatb & PNG_FORMAT_FLAG_LINEAR) /* 16-bit checks */ { - png_const_uint_16p pua = (png_const_uint_16p)psa; - png_const_uint_16p pub = (png_const_uint_16p)psb; + png_const_uint_16p pua = aligncastconst(png_const_uint_16p, psa); + png_const_uint_16p pub = aligncastconst(png_const_uint_16p, psb); switch (bchannels) {