[PATCH] (Title Corrected) Build fails to compile jchuff.c using gcc 4.8.5 on zLinux

Adam Farley8 adam.farley at uk.ibm.com
Wed Jan 17 11:50:27 UTC 2018

Hi All,

If you compile jchuff.c (part of javajpeg) without 
then you get an error that kills the build. This is seen in these 

Build: JDK9
gcc and g++ Version: 4.8.5
Platform: zLinux 64bit (s390x)

The error message is: 

In function 'jGenOptTbl':
error: array subscript is below array bounds [-Werror=array-bounds]
      while (bits[j] == 0)

It looks to me that this error happens because the while loop can 
reduce j down to beneath 0, resulting in us attempting to find the array 
with index -1.

On the basis that if we get down to -1 here bad things will happen 
perhaps we should change that line to:

      while ((bits[j] == 0) && (j != 0))

This appears to prevent the compiler failing with this error, by providing 

unambiguous handling for the "index -1" scenario.


Best Regards

Adam Farley

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

More information about the build-dev mailing list