This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcj bug


Originator: Daniel Alexander
Organisation: UCL (University College London)
Synopsis: Using gcj to compile java code, pre-increment operator (++)
fails (does not increment) on bracketed elements of integer arrays, e.g,
++(ip[i]) leaves ip[i] unchanged.
Severity: serious.
Priority: medium.
Category: java
Release:
    Reading specs from
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.4/specs
    Reading specs from
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.4/libgcj.spec
    rename spec lib to liborig
    rename spec startfile to startfileorig
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --datadir=/usr/share/gcc-3.0.4 --enable-shared
--enable-threads=posix --disable-checking --enable-long-long
--enable-cstdio=stdio --enable-clocale=generic
--enable-languages=c,c++,f77,objc,java --program-suffix=-3.0.4
--enable-objc-gc --host=i586-mandrake-linux-gnu --with-system-zlib
    Thread model: posix
    gcc version 3.0.4 (Mandrake Linux 8.2 3.0.4-2mdk)
Environment
    %uname -a
    Linux maraca.cs.ucl.ac.uk 2.4.18-6mdkenterprise #1 SMP Fri Mar 15
02:28:20 CET 2002 i686 unknown
Description
    The pre-increment operator does not work (no increment occurs) when
applied to a bracketed element of an integer array. Simple example
source code below:

public class BugTest {

        public static void main(String[] args) {
                int n=5;
                int[] ipiv = new int[n+1];
                for(int i=1; i<=n; i++) {
                        ipiv[i] = 0;
                        System.out.print(i + " " + ipiv[i] + " ");
                        ++(ipiv[i]);
                        System.out.println(ipiv[i]);
                }
        }
}

  Expected output of BugTest.java:
1 0 1
2 0 1
3 0 1
4 0 1
5 0 1

    Actual output:
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0

How-To-Repeat: Try simple test program above.

Fix: Use post-increment or ipiv[i] += 1.

Compilation command line: gcj --main=BugTest -o BugTest BugTest.java

Attached file, BugTestmain.i, obtained via command line:
gcj -v -save-temps --main=BugTest -o BugTest BugTest.java

Daniel Alexander
Dept. Computer Science
UCL
Gower Street
London
WC1E 6BT
UK
extern const char **_Jv_Compiler_Properties;
static const char *props[] =
{
  0
};

extern int _ZN7BugTest6class$E;
int main (int argc, const char **argv)
{
   _Jv_Compiler_Properties = props;
   JvRunMain (&_ZN7BugTest6class$E, argc, argv);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]