Bug 118219

Summary: gjc internal error: Segmentation fault involving switch to a final var
Product: [Retired] Red Hat Linux Reporter: Larry Morell <morell>
Component: gccAssignee: Andrew Haley <aph>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-03-15 17:56:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Larry Morell 2004-03-13 20:12:16 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1)
Gecko/20030225

Description of problem:
Compiling:
class BugToken {
   public void oops () {
       final char eofSym;
       switch (7) {
          case eofSym    : ;
       }
   }

}

yields:
javac BugToken.java
BugToken.java: In class `BugToken':
BugToken.java: In method `BugToken.oops()':
BugToken.java:4: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Removing 'final' yields:


BugToken.java: In class `BugToken':
BugToken.java: In method `BugToken.oops()':
BugToken.java:5: Constant expression required.
             case eofSym    : ;
             ^
1 error

as hoped.

Version-Release number of selected component (if applicable):
gcc-3.2.2-5

How reproducible:
Always

Steps to Reproduce:
1. Using javac script supplied with Redhat 9 compile the program:class
BugToken {
   public void oops () {
       assinal char eofSym;
       switch (7) {
          case eofSym    : ;
       }
   }

}
   

Actual Results:  javac BugToken.java
BugToken.java: In class `BugToken':
BugToken.java: In method `BugToken.oops()':
BugToken.java:4: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.


Expected Results:  Should have compiled.

Additional info:

Comment 1 Jakub Jelinek 2004-03-15 13:11:14 UTC
*** Bug 118220 has been marked as a duplicate of this bug. ***

Comment 2 Andrew Haley 2004-03-15 15:18:04 UTC
2004-03-15  Andrew Haley  <aph>

	* parse.y (java_complete_lhs): Check that final variable has an
	initializer.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.472
diff -p -2 -c -r1.472 parse.y
*** parse.y	28 Feb 2004 00:34:25 -0000	1.472
--- parse.y	15 Mar 2004 15:22:24 -0000
*************** java_complete_lhs (tree node)
*** 11654,11658 ****
  	}
        /* Accept final locals too. */
!       else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn))
  	cn = fold_constant_for_init (DECL_INITIAL (cn), cn);
  
--- 11654,11659 ----
  	}
        /* Accept final locals too. */
!       else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn) 
! 	       && DECL_INITIAL (cn))
  	cn = fold_constant_for_init (DECL_INITIAL (cn), cn);
  

Comment 3 Andrew Haley 2004-03-15 17:56:39 UTC
Checked in to cvs HEAD.  This will be fixed in gcc 3.5.