Issue of the Implementation # S0846


get_crc_table return value type doesn't corresponds to LSB (x86_64 only)

Detailed Description

LSB states that get_crc_table() shall return a pointer to unsigned long int value.

Comment from zlib github:
Apr 29, 2012
Fix type mismatch between get_crc_table() and crc_table. … crc_table is made using a four-byte integer (when that can be determined). However get_crc_table() returned a pointer to an unsigned long, which could be eight bytes. This fixes that by creating a new z_crc_t type for the crc_table.

z_crc_t is defined as:

#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
#  include 
#  if (UINT_MAX == 0xffffffffUL)
#    define Z_U4 unsigned
#  else
#    if (ULONG_MAX == 0xffffffffUL)
#      define Z_U4 unsigned long
#    else
#      if (USHRT_MAX == 0xffffffffUL)
#        define Z_U4 unsigned short
#      endif
#    endif
#  endif

#ifdef Z_U4
   typedef Z_U4 z_crc_t;
   typedef unsigned long z_crc_t;
For LSB compliant distros UINT_MAX is 0xffffffffU. Thus return type is a pointer to unsigned int that contradicts LSB.
This problem is x86_64 only, because int and long are the same in 32-bit systems.


zlib 1.2.7


problem origin