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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ messages in thread

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <bug-13788-7763@http.gcc.gnu.org/bugzilla/>
  2005-10-13  1:11 ` cvs-commit at gcc dot gnu dot org
@ 2005-10-13  1:14 ` mckinlay at redhat dot com
  1 sibling, 0 replies; 10+ messages in thread
From: mckinlay at redhat dot com @ 2005-10-13  1:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from mckinlay at redhat dot com  2005-10-13 01:14 -------
Fixed checked in to 4.0 branch.


-- 

mckinlay at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.1.0                       |4.0.3


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <bug-13788-7763@http.gcc.gnu.org/bugzilla/>
@ 2005-10-13  1:11 ` cvs-commit at gcc dot gnu dot org
  2005-10-13  1:14 ` mckinlay at redhat dot com
  1 sibling, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-13  1:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from cvs-commit at gcc dot gnu dot org  2005-10-13 01:11 -------
Subject: Bug 13788

CVSROOT:        /cvs/gcc
Module name:    gcc
Branch:         gcc-4_0-branch
Changes by:     bryce@gcc.gnu.org       2005-10-13 01:11:27

Modified files:
        gcc/java       : ChangeLog parse.y 
        libjava        : ChangeLog 
        libjava/testsuite/libjava.jacks: jacks.xfail 
Added files:
        libjava/testsuite/libjava.compile: pr13788.java pr21540.java 

Log message:
        gcc/java:
        2005-10-12  Tom Tromey  <tromey@redhat.com>

        PR java/21540, PR java/13788:
        * parse.y (java_complete_lhs) <CASE_EXPR>: Use
        fold_constant_for_init.
        (patch_binop): Added 'folding' argument.  Updated all callers.
        (patch_unaryop) <NOP_EXPR>: New case.
        (fold_constant_for_init) <NOP_EXPR>: Likewise.
        (fold_constant_for_init) <COND_EXPR>: Fix sense of test.

        libjava:
        2005-10-12  Andreas Tobler  <a.tobler@schweiz.ch>

        * testsuite/libjava.jacks/jacks.xfail: Remove 15.21-assoc-7,
        15.21-assoc-8, 15.21-equal-3, 15.28-string-11.

        2005-10-12  Tom Tromey  <tromey@redhat.com>

        PR java/21540, PR java/13788:
        * testsuite/libjava.compile/pr21540.java: New file.
        * testsuite/libjava.compile/pr13788.java: New file.
        * testsuite/libjava.jacks/jacks.xfail: Updated.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1556.2.35&r2=1.1556.2.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.528.6.5&r2=1.528.6.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.105&r2=1.3391.2.106
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr13788.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.22.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr21540.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.22.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jacks/jacks.xfail.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.19.8.3&r2=1.19.8.4


-- 


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <20040121055330.13788.meganandaj@pacific.net.au>
                   ` (3 preceding siblings ...)
  2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-27 18:41 ` tromey at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-27 18:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-27 18:41 -------
I checked this in to cvs trunk.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <20040121055330.13788.meganandaj@pacific.net.au>
                   ` (2 preceding siblings ...)
  2005-06-27 16:59 ` tromey at gcc dot gnu dot org
@ 2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
  2005-06-27 18:41 ` tromey at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-27 18:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-27 18:40 -------
Subject: Bug 13788

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-06-27 18:40:17

Modified files:
	libjava        : ChangeLog 
	gcc/java       : ChangeLog parse.y 
	libjava/testsuite/libjava.jacks: jacks.xfail 
Added files:
	libjava/testsuite/libjava.compile: pr13788.java pr21540.java 

Log message:
	gcc/java/:
	PR java/21540, PR java/13788:
	* parse.y (java_complete_lhs) <CASE_EXPR>: Use
	fold_constant_for_init.
	(patch_binop): Added 'folding' argument.  Updated all callers.
	(patch_unaryop) <NOP_EXPR>: New case.
	(fold_constant_for_init) <NOP_EXPR>: Likewise.
	(fold_constant_for_init) <COND_EXPR>: Fix sense of test.
	libjava/:
	PR java/21540, PR java/13788:
	* testsuite/libjava.compile/pr21540.java: New file.
	* testsuite/libjava.compile/pr13788.java: New file.
	* testsuite/libjava.jacks/jacks.xfail: Updated.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3679&r2=1.3680
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1634&r2=1.1635
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.541&r2=1.542
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr13788.java.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/pr21540.java.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.jacks/jacks.xfail.diff?cvsroot=gcc&r1=1.24&r2=1.25



-- 


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <20040121055330.13788.meganandaj@pacific.net.au>
  2005-06-24 21:49 ` tromey at gcc dot gnu dot org
  2005-06-27 16:52 ` tromey at gcc dot gnu dot org
@ 2005-06-27 16:59 ` tromey at gcc dot gnu dot org
  2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
  2005-06-27 18:41 ` tromey at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-27 16:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-27 16:59 -------
I'm testing a fix.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-05-21 12:55:00         |2005-06-27 16:59:15
               date|                            |


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <20040121055330.13788.meganandaj@pacific.net.au>
  2005-06-24 21:49 ` tromey at gcc dot gnu dot org
@ 2005-06-27 16:52 ` tromey at gcc dot gnu dot org
  2005-06-27 16:59 ` tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-27 16:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-27 16:52 -------
The problem here is that the code in patch_binop that
converts URSHIFT_EXPR to RSHIFT_EXPR modifies the type and
code of the tree in place -- but that is incorrect as it misses
the final cast back to a signed type.


-- 


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


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

* [Bug java/13788] Zero propogate right shift in static final int initializer causes error
       [not found] <20040121055330.13788.meganandaj@pacific.net.au>
@ 2005-06-24 21:49 ` tromey at gcc dot gnu dot org
  2005-06-27 16:52 ` tromey at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-24 21:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-24 21:49 -------
FWIW I agree with the analysis.
This is related to PR 21540, but not the same.


-- 


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


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

end of thread, other threads:[~2005-10-13  1:14 UTC | newest]

Thread overview: 10+ 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
     [not found] <20040121055330.13788.meganandaj@pacific.net.au>
2005-06-24 21:49 ` tromey at gcc dot gnu dot org
2005-06-27 16:52 ` tromey at gcc dot gnu dot org
2005-06-27 16:59 ` tromey at gcc dot gnu dot org
2005-06-27 18:40 ` cvs-commit at gcc dot gnu dot org
2005-06-27 18:41 ` tromey at gcc dot gnu dot org
     [not found] <bug-13788-7763@http.gcc.gnu.org/bugzilla/>
2005-10-13  1:11 ` cvs-commit at gcc dot gnu dot org
2005-10-13  1:14 ` mckinlay at redhat dot com

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