-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
1.1
-
sparc
-
solaris_2.5
Name: sgC58550 Date: 03/17/97
I do think the compiler should warn when int (long) ist
implicitely converted to float (double). I got an endless
loop which was not so easy to find. Basically the following
code shows what happens:
class Test {
public static void main(String argv[]) {
int i;
float j=1;
for(i=0;i<33554432;i+=j)
if (i % 1000000 == 0) System.out.print(i);
}
}
With today's computation power and memory sizes a loop of
this proportion is not so unlikely. The ultra I use arrives
at the problematic point in less than a minute.
Considering that the only "error" in the above is the
declaration of j as int, I consider this "feature" to be
dangerous. If someone wants to conserve memory such an use
of a float is not so unlikely. As this problem is possibly
not found in a test-run (small values) but will cause trouble
when it counts (large values), I belive an appropriate warning
or even a required cast should be added.
Best Regards
Arno Wagner
(Dipl. Inform.)
company - Univesity of Karlsruhe, Dept. of Informatics , email - ###@###.###
======================================================================
- relates to
-
JDK-5009476 Compound assignments don't work well with Byte, Short
- Open