public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/19277] New: allows array.length++ although it is final
@ 2005-01-05 19:50 kon at iki dot fi
  2005-01-05 20:39 ` [Bug java/19277] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kon at iki dot fi @ 2005-01-05 19:50 UTC (permalink / raw)
  To: java-prs

GCC checked out on 2005-01-03 compiles the following code without
complaint, using the command line "gcj -C -Wall -W -pedantic
ArrayLength.java":

class ArrayLength {
    static int extend(int[] array) {
        /* array.length = 1; */
        array.length++;
        return array.length;
    }
}

It generates the following bytecode for the method:

  0: aload_0
  1: dup
  2: getfield <Field [I.length int>
  5: iconst_1
  6: iadd
  7: putfield <Field [I.length int>
 10: aload_0
 11: arraylength
 12: ireturn

However, if I uncomment the first assignment, I get this error:

ArrayLength.java: In class 'ArrayLength':
ArrayLength.java: In method 'ArrayLength.extend(int[])':
ArrayLength.java:3: error: Can't reassign a value to the final variable 'length'.
        array.length = 1;
  ^
1 error

I think it is inconsistent to allow ++ if the field is final.

-- 
           Summary: allows array.length++ although it is final
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kon at iki dot fi
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


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


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

end of thread, other threads:[~2005-01-10 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-05 19:50 [Bug java/19277] New: allows array.length++ although it is final kon at iki dot fi
2005-01-05 20:39 ` [Bug java/19277] " pinskia at gcc dot gnu dot org
2005-01-10 11:02 ` rmathew at gcc dot gnu dot org
2005-01-10 18:01 ` cvs-commit at gcc dot gnu dot org
2005-01-10 18:07 ` cvs-commit at gcc dot gnu dot org
2005-01-10 19:10 ` pinskia at gcc dot gnu dot org

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).