public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/6391: Constant float to int conversions don't use ieee_real_to_integer when compiled to byte-code
@ 2002-04-21  2:46 mark
  0 siblings, 0 replies; 2+ messages in thread
From: mark @ 2002-04-21  2:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6391
>Category:       java
>Synopsis:       Constant float to int conversions don't use ieee_real_to_integer when compiled to byte-code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 21 02:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     mark@klomp.org
>Release:        gcj 3.1
>Organization:
>Environment:

>Description:
See also the following thread:
http://gcc.gnu.org/ml/java/2002-04/msg00255.html

The following program:

public class DFT
{
        public static void main(String[] args)
        {
                System.out.println((int) 3.4e+32);
                System.out.println((long) 3.4e+32);

                System.out.println((int) 3.4e+32f);
                System.out.println((long) 3.4e+32f);
        }
}

Should produce the following output (which is does when compiling to native code):

2147483647
9223372036854775807
2147483647
9223372036854775807

But when compiling to byte-code it gives:

0
-4294967296
0
-4294967296

The problem seemed to be solved by the following patch  which makes sure that even when we emit a class file the special convert_ieee_real_to_integer is used and not just convert_to_integer.

diff -u -r1.44 typeck.c
--- typeck.c    3 Dec 2001 23:09:42 -0000       1.44
+++ typeck.c    19 Apr 2002 22:17:05 -0000
@@ -134,7 +134,6 @@
   if (code == INTEGER_TYPE)
     {
       if (! flag_unsafe_math_optimizations
-         && ! flag_emit_class_files
          && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
          && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
        return fold (convert_ieee_real_to_integer (type, expr));

Sadly this is not the solution since with this patch I get one regression: FAIL: Primes -O output from bytecode->native test

And although the above test program and the Mauve FloatTest produce correct results the Mauve DoubleTest now gives:

gnu/testlet/java/lang/Double/DoubleTest.java: In class
`gnu.testlet.java.lang.Double.DoubleTest':
gnu/testlet/java/lang/Double/DoubleTest.java: In method
`gnu.testlet.java.lang.Double.DoubleTest.test_longValue()':
gnu/testlet/java/lang/Double/DoubleTest.java:310: verification error at
PC=32
gnu/testlet/java/lang/Double/DoubleTest.java:310: invalid argument type
gnu/testlet/java/lang/Double/DoubleTest.java:310: expected type
'boolean' but stack contains 'void'
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: java/6391: Constant float to int conversions don't use ieee_real_to_integer when compiled to byte-code
@ 2002-05-11 17:44 tromey
  0 siblings, 0 replies; 2+ messages in thread
From: tromey @ 2002-05-11 17:44 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, java-prs, mark, nobody

Synopsis: Constant float to int conversions don't use ieee_real_to_integer when compiled to byte-code

State-Changed-From-To: open->analyzed
State-Changed-By: tromey
State-Changed-When: Sat May 11 17:44:36 2002
State-Changed-Why:
    I looked at this a bit today.
    The problem is that fold_convert() isn't using java semantics.
    We need some way to tell it about this difference between
    C and Java.
    I'm not exactly sure what how that should happen; I'll ask.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6391


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-12  0:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-21  2:46 java/6391: Constant float to int conversions don't use ieee_real_to_integer when compiled to byte-code mark
2002-05-11 17:44 tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).