This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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]

Method Invocation: Argument Evaluation Order


Hi,

    According to the JLS (section 15.12.4.2, "Evaluate Arguments")
while evaluating the arguments passed to a method invocation:

http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#45449

"The argument expressions are evaluated in order, from left to right..."

Therefore the following program should output (as it indeed
does with the Sun JDK 1.3.1):

a = 0
b = 1

But instead, with GCJ 3.2 on Solaris, it outputs:

a = 1
b = 1

The program in question is:
-------------------------- 8< ----------------------------
public class PreIncr
{
    private int i = 0;

    public static void main( String[] args)
    {
        new PreIncr( ).doIt( );
    }

    private void doIt( )
    {
        this.printAB( i, ++i);
    }

    private void printAB( int a, int b)
    {
        System.out.println( "a = " + a);
        System.out.println( "b = " + b);
    }
}
-------------------------- 8< ----------------------------

Isn't this a bug? Or am I missing something here?

Ranjit.

--
Ranjit Mathew          Email: rmathew AT hotmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/




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