public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/13788] New: Zero propogate right shift in static final int initializer causes error
@ 2004-01-21  5:53 andrew dot gray at anu dot edu dot au
  2004-01-21  6:03 ` [Bug java/13788] " pinskia at gcc dot gnu dot org
  2004-01-21  6:17 ` andrew dot gray at anu dot edu dot au
  0 siblings, 2 replies; 3+ messages in thread
From: andrew dot gray at anu dot edu dot au @ 2004-01-21  5:53 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
  2004-01-21  5:53 [Bug java/13788] New: Zero propogate right shift in static final int initializer causes error andrew dot gray at anu dot edu dot au
@ 2004-01-21  6:03 ` pinskia at gcc dot gnu dot org
  2004-01-21  6:17 ` andrew dot gray at anu dot edu dot au
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-21  6:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-21 06:03 -------
Confirmed but this is only rejected when compiling to native code which is weird. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-21 06:03:13
               date|                            |


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
  2004-01-21  5:53 [Bug java/13788] New: Zero propogate right shift in static final int initializer causes error andrew dot gray at anu dot edu dot au
  2004-01-21  6:03 ` [Bug java/13788] " pinskia at gcc dot gnu dot org
@ 2004-01-21  6:17 ` andrew dot gray at anu dot edu dot au
  1 sibling, 0 replies; 3+ messages in thread
From: andrew dot gray at anu dot edu dot au @ 2004-01-21  6:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From andrew dot gray at anu dot edu dot au  2004-01-21 06:17 -------
I have a feeling that the "weirdness" could be explained by the
"! flag_emit_class_files" in the following lines:

     /* The >>> operator is a >> operating on unsigned quantities */
      if (code == URSHIFT_EXPR && ! flag_emit_class_files)

from java/parse.y (lines 13428 & 13429 in the 2004-01-14 snapshot I have)
in the patch_binop function under the URSHIFT_EXPR case.

As far as I can tell the code in the body of this if statement converts
the zero propogate right shift to a right shift on an unsigned int and a
cast back to int, which then causes the error I am seeing.  However, I have
virtually zero experience with this code, so I didn't get any further than
this guess.

-- 


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


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

end of thread, other threads:[~2004-01-21  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-21  5:53 [Bug java/13788] New: Zero propogate right shift in static final int initializer causes error andrew dot gray at anu dot edu dot au
2004-01-21  6:03 ` [Bug java/13788] " pinskia at gcc dot gnu dot org
2004-01-21  6:17 ` andrew dot gray at anu dot edu dot au

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