This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

java/2155: Overzealous detection of uninitialized final variables



>Number:         2155
>Category:       java
>Synopsis:       Overzealous detection of uninitialized final variables
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 02 19:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Bryce McKinlay
>Release:        gcc version 3.0 20010302 (prerelease)
>Organization:
>Environment:

>Description:
Try to compile the test case below. This code is legal,
but gcj rejects it with the following error:


$ gcj -c Final.java 
Final.java: In class `Final':
Final.java: In method `()':
Final.java:9: Can't assign a value to the final variable `foo'.
       foo = 22;
       ^
Final.java: At top level:
Final.java:6: Final variable `foo' hasn't been initialized upon its declaration.
     final int foo;
               ^
2 errors

It seems that this is a regression caused by the PR java/1212 fix.

>How-To-Repeat:
// Uninitalized final variables are not permitted, but they don't 
// neccessarily have to be initialized inline.

class Final
{
  final int foo;
  
  {
    foo = 22;
  }
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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