This is an example code to reproduce the problem:
//---------------------------------------------
public class Test {
        public static void main(String[] s){
                log2( 1 );
                log2( 2 );
                log2( 4 );
                log2( 8 );
                log2( 16 );
                log2( 32 );
                log2( 64 );
        }

    public static void log2( int value ){
        double aux = (Math.log( value ) / Math.log(2.0) );
        int value1 = (int)aux;
        int value2 = (int)(Math.log( value ) / Math.log(2.0) );
        System.out.println( value1 + "  " + value2 );
    }
}
//---------------------------------------------

if i build it as .class file, it give that results:
gcj -C Test.java
gij Test
0  0
1  1
2  2
3  3
4  4
5  5
6  6

but if i build it as native:
gcj -c -o Test.o Test.java
gcj --main=Test -o Test Test.o
./Test
0  0
1  1
2  2
3  2
4  4
5  5
6  5


-- 
           Summary: (int) cast return different results beetween .class and
                    native
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: julian at casadesus dot com dot ar


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32939

Reply via email to