[Bug java/13788] New: Zero propogate right shift in static final int initializer causes error

andrew dot gray at anu dot edu dot au gcc-bugzilla@gcc.gnu.org
Wed Jan 21 05:53:00 GMT 2004


Overview description
--------------------
Using the zero propogate right shift operator (>>>) with constant operands
in a static final int initializer causes a compilation error in gcj.

Steps to reproduce
------------------
1) Create the RShiftInInitializer.java source file with the following contents:

class RShiftInIntInitializer {
  private static final int  DUMMY1 = 1 >>> 1;

  public static void main(String [] args) {
    System.out.println(DUMMY1);
  }
}

2) Run the following gcj command:
gcj --main=RShiftInIntInitializer RShiftInIntInitializer.java

Actual results
--------------
The gcj command produced the following output:
RShiftInIntInitializer.java: In class `RShiftInIntInitializer':
RShiftInIntInitializer.java: In method `<clinit>()':
RShiftInIntInitializer.java:2: error: Incompatible type for declaration.
Explicit cast needed to convert `unsigned int' to `int'.
     private static final int  DUMMY1 = 1 >>> 1;
                               ^
1 error

Expected results
----------------
I expect gcj to produce no error messages and create an a.out file that when
run would produce the following output:
0
This is what happened when I used the javac and java tools from Sun's J2SE SDK
v1.4.1 to compile and run the RShiftInInitializer.java code.

Version and platform
--------------------
Version of GCC: 3.4.0 20040114 (experimental)

System type: i686-pc-linux-gnu

Options given when GCC was configured:
../gcc-3.4-20040114/configure --prefix=/home/andrewg/gcc-3.4-20040114-install
--enable-threads=posix --enable-shared --enable-languages=c++,java

The problem was also seen with the following versions of GCC:
3.2.2 20030222 (Red Hat Linux 3.2.2-5)
3.3.2

-- 
           Summary: Zero propogate right shift in static final int
                    initializer causes error
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot gray at anu dot edu dot au
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list