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

David Holmes david.holmes at oracle.com
Wed Jan 17 12:09:59 UTC 2018


Hi Adam,

This seems to be a gcc bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124

I'm assuming that the code is actually written in such a way that the 
index will never actually go negative (due to what has been written 
previously).

The right fix here would be to disable the warning in gcc 4.x.

David

On 17/01/2018 9:50 PM, Adam Farley8 wrote:
> Hi All,
> 
> If you compile jchuff.c (part of javajpeg) without
> "--disable-warnings-as-errors",
> then you get an error that kills the build. This is seen in these
> circumstances:
> 
> Build: JDK9
> gcc and g++ Version: 4.8.5
> Platform: zLinux 64bit (s390x)
> 
> The error message is:
> 
> /home/adamfarl/hotspot/jdk9/jdk/src/java.desktop/share/native/libjavajpeg/jchuff.c:
> In function 'jGenOptTbl':
> /home/adamfarl/hotspot/jdk9/jdk/src/java.desktop/share/native/libjavajpeg/jchuff.c:808:18:
> 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
> technically
> reduce j down to beneath 0, resulting in us attempting to find the array
> entry
> with index -1.
> 
> On the basis that if we get down to -1 here bad things will happen
> regardless,
> 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.
> 
> Thoughts?
> 
> Best Regards
> 
> Adam Farley
> 
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
> 


More information about the build-dev mailing list