This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: libjava Divide_1 and pr6388 fail on 4.2.0 RC3 for several targets
- From: Ian Lance Taylor <iant at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: David Daney <ddaney at avtrex dot com>, Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>, java at gcc dot gnu dot org, gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, mark at codesourcery dot com
- Date: 07 May 2007 17:38:55 -0700
- Subject: Re: libjava Divide_1 and pr6388 fail on 4.2.0 RC3 for several targets
- References: <20070506.110229.74748979.kkojima@rr.iij4u.or.jp> <463D47A8.1070704@avtrex.com> <m3k5vk34dr.fsf@localhost.localdomain> <17983.48852.944170.79487@localhost.localdomain>
Tom Tromey <tromey@redhat.com> writes:
> >>>>> "Ian" == Ian Lance Taylor <iant@google.com> writes:
>
> Ian> This is a bug in C++ code in libjava.
>
> Thanks. We enabled -fwrapv for the interpreter but, I think, thought
> that perhaps the other C++ code was safe.
> Would the new warning have caught this?
Yes. With -Wstrict-overflow:
../../../trunk/libjava/java/lang/natString.cc: In function ‘jint _Jv_FormatInt(jchar*, jint)’:
../../../trunk/libjava/java/lang/natString.cc:375: warning: assuming signed overflow does not occur when simplifying conditional to constant
It also warns about this sort of code which occurs a few times in that
file:
if (offset < 0 || count < 0 || offset + count < 0
|| offset + count > data_size)
Since if offset < 0 and count < 0, then VRP can assume that offset +
count < 0 is always true. If you want to code to correctly check for
signed overflow of offset + count, you will need to instead write
something along the lines of INT_MAX - offset <= count.
Ian