This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [Patch] PR java/22113: Fix buffer overflow in Java lexer for FP literals
On 8/17/05, Eric Blake <ebb9@byu.net> wrote:
>
> Literal token length is technically unlimited - the longest string
> possible that still parses as a floating point number without causing
> overflow or underflow must be parsed as such. However, there IS a fixed
> maximum length of significant characters at which the decision of which
> exact 2's complement number the decimal string will round to (or can be
> determined simply by scanning for the first non-zero digit after that
> length); this limit is determined by the actual base-10 representation of
> the 1ulp 2's complement denormal. I wrote the jacks tests in question,
> which purposefully use a 800+ character mantissa of the halfway point
> between the smallest two denormals, as the longest string of non-zero
> characters where rounding can make a difference. I don't remember the
> exact number of significant characters, but you can reverse engineer that
> from the jacks test. Remember that you need to strip leading zeros of
> both the mantissa and exponent before starting to count characters towards
> the limit; fortunately, Java has no way to stringize a literal so you only
> need to obtain the exact value rather than preserve the original string.
>
> On the other hand, since every possible double can be expressed with a
> decimal string with a maximum of 24 characters (and even fewer characters
> with hex-float literals in Java 1.5 syntax), only brain-dead compiler test
> suites are ever likely to give you a literal with more than 256 characters :)
Thank you for the excellent (as always) explanation Eric!
I have created PR java/23432 to track this issue:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23432
where the testcase shows that we don't even accept
a large expansion of pi, while Jikes and javac do.
Thanks,
Ranjit.
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/