java/2312: Check for initialization of all final fields erronously fails
bryce@albatross.co.nz
bryce@albatross.co.nz
Sat Mar 17 20:56:00 GMT 2001
>Number: 2312
>Category: java
>Synopsis: Check for initialization of all final fields erronously fails
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Mar 17 20:56:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Bryce McKinlay
>Release: gcc version 3.0 20010317 (prerelease)
>Organization:
>Environment:
>Description:
Compilation of the test case below fails because GCJ
falsely determines that all the classes final fields may
not have been initialized:
$ gcj -c Final.java
Final.java:11: Final variable initialization error in this constructor.
{
^
1 error
The problem appears to be with the method
check_final_variable_indirect_assignment.
The workaround below permits correct compilation, but
disables the final variable checking completely.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.251.2.7
diff -u -r1.251.2.7 parse.y
--- parse.y 2001/03/17 21:53:11 1.251.2.7
+++ parse.y 2001/03/18 04:50:46
@@ -12271,6 +12271,10 @@
if (fbody == error_mark_node)
continue;
fbody = BLOCK_EXPR_BODY (fbody);
+
+ DECL_FUNCTION_ALL_FINAL_INITIALIZED (mdecl) = 1;
+
+ /*
if (check_final_variable_indirect_assignment (fbody) == 1)
{
DECL_FUNCTION_ALL_FINAL_INITIALIZED (mdecl) = 1;
@@ -12280,6 +12284,7 @@
parse_error_context
(lookup_cl (mdecl),
"Final variable initialization error in this constructor");
+ */
}
else
nnctor++;
>How-To-Repeat:
class Final
{
private final Integer foo;
Final (Integer f)
{
foo = f;
}
Final ()
{
this (new Integer(9));
}
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list