What's the idea behind the png_constcast() macro implementation?
Stephan Mühlstrasser <[email protected]> Fri, 2 Feb 2018 09:20:29 +0100
| Newsgroups | gmane.comp.graphics.png.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
among other platforms we are using libpng on IBM iSeries. After
upgrading from an older version to libpng 1.6.34 we are getting crashes
in libpng code. It looks like the following construct in pngpriv.h is
responsible for the crashes:
# ifdef _WIN64
# ifdef __GNUC__
typedef unsigned long long png_ptruint;
# else
typedef unsigned __int64 png_ptruint;
# endif
# else
typedef unsigned long png_ptruint;
# endif
# define png_constcast(type, value) ((type)(png_ptruint)(const
void*)(value))
On IBM iSeries it is not possible to cast pointer types to integer types
and back to pointer types. See for example here:
https://www.ibm.com/support/knowledgecenter/SSAE4W_9.6.0/com.ibm.etools.iseries.pgmgd.doc/cpprog448.htm
The question is, what is the idea behind the intermediate cast to
png_ptruint in the png_constcast() macro, before the (type) cast is
applied? I did a quick test with gcc on Linux and Visual Studio on
Windows, and leaving out the (png_ptruint) did not cause a warning.
Thanks
Stephan
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot