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]

[Bug java/13720] New: gcc/libjava/java/lang/natSystem.cc: syntax error using "unsigned jint"


Hello,

I tried to compile libjava to try out the GDK/GTK awt peer. When compiling with
gcc-3.3.3, i got a syntax error in `array_copy', where the source code is:

    ... if ((unsigned jint) src_offset ...

jint is typedef'd to __java_int and so there are two ID tokens in the
parentheses, not one type-ID. Maybe gcc-3.4 can handle this, but I would rather
apply this patch:

Index: natSystem.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/natSystem.cc,v
retrieving revision 1.56
diff -u -r1.56 natSystem.cc
--- natSystem.cc        23 Jul 2003 15:31:43 -0000      1.56
+++ natSystem.cc        17 Jan 2004 15:20:27 -0000
@@ -66,10 +66,12 @@
   __JArray *src_a = (__JArray *) src;
   __JArray *dst_a = (__JArray *) dst;
   if (src_offset < 0 || dst_offset < 0 || count < 0
-      || (unsigned jint) src_offset > (unsigned jint) src_a->length
-      || (unsigned jint) (src_offset + count) > (unsigned jint) src_a->length
-      || (unsigned jint) dst_offset > (unsigned jint) dst_a->length
-      || (unsigned jint) (dst_offset + count) > (unsigned jint) dst_a->length)
+      || src_offset > src_a->length
+      || src_offset - (-count) >= 0 // check for possible integer overflow
+      || src_offset + count > src_a->length
+      || dst_offset > dst_a->length
+      || dst_offset - (-count) >= 0 // check for possible integer overflow
+      || dst_offset + count > dst_a->length)
     throw new ArrayIndexOutOfBoundsException;
 
   // Do-nothing cases.

-- 
           Summary: gcc/libjava/java/lang/natSystem.cc: syntax error using
                    "unsigned jint"
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: roland dot illig at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-debian-linux-gnu
  GCC host triplet: i686-debian-linux-gnu
GCC target triplet: i686-debian-linux-gnu


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


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