User account creation filtered due to spam.

Bug 11075 - Compiling cross-package inherited constants are rejected
Summary: Compiling cross-package inherited constants are rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2003-06-03 08:42 UTC by Robin Garner
Modified: 2007-01-09 20:45 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-05-21 02:43:07


Attachments
Test case (482 bytes, application/octet-stream)
2003-06-03 08:48 UTC, Robin Garner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Garner 2003-06-03 08:42:31 UTC
gcj crashes with an ICE when compiling the following code (3 files):

P/a.java:
package P;
class a { static final int A = 2; }

P/b.java:
package P;
public interface b { static int B = a.A; }

Q/c.java:
package Q;
import P.b;
class c {
  static int x; { x = b.B; }  // Virtually any reference to b.B works here
}

gcj -c  P/a.java
gcj -c  P/b.java
gcj -c  Q/c.java
c.java:4: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Configuration details follow:

$ gcc -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../gcc-3.3/configure
Thread model: posix
gcc version 3.3

$ uname -a
Linux r105l05.anu.edu.au 2.4.18 #2 SMP Thu Jul 11 13:10:05 EST 2002 i686 unknown

No intermediate files generated.

Also reproduced under gcc-3.2.2, and on an RH 7.1 system (i686) with 3.2.2.
Comment 1 Robin Garner 2003-06-03 08:48:31 UTC
Created attachment 4150 [details]
Test case

gzipped tar file: tar -cvzf test_11075.tgz test_11075
test_11075/
test_11075/test
test_11075/P/
test_11075/P/a.java
test_11075/P/b.java
test_11075/Q/
test_11075/Q/c.java
Comment 2 Andrew Pinski 2003-06-03 12:21:25 UTC
Also fails on the mainline (20030602):
Program received signal SIGSEGV, Segmentation fault.
0x0806dbc6 in resolve_qualified_expression_name (wfl=0x4004c640, found_decl=
0x21, where_found=0xbffebe14, type_found=0xbffebe18) at parse.y:9692
9692                     GET_TYPE_NAME (type),
(gdb) bt
#0  0x0806dbc6 in resolve_qualified_expression_name (wfl=0x4004c640, found_decl=
0x21, where_found=0xbffebe14, type_found=0xbffebe18) at parse.y:9692
#1  0x0806be39 in resolve_field_access (qual_wfl=0x21, field_decl=0xbffebe58, 
field_type=0x0) at parse.y:9268
#2  0x0808baf3 in fold_constant_for_init (node=0x4004c640, context=0x40078d80) at 
parse.y:15992
#3  0x0808b305 in maybe_build_class_init_for_field (decl=0x400b51b8, expr=
0x40078d80) at parse.y:15864
#4  0x0806c0fe in resolve_field_access (qual_wfl=0x21, field_decl=0x0, field_type=0x0) 
at parse.y:9307
#5  0x0806b88b in resolve_expression_name (id=0x4004c4e0, orig=0x0) at 
parse.y:9229
#6  0x080783ba in java_complete_lhs (node=0x4004c4e0) at parse.y:11808
#7  0x08074e82 in java_complete_tree (node=0x4004c4e0) at parse.y:11433
#8  0x08078b41 in java_complete_lhs (node=0x400550a8) at parse.y:12016
#9  0x08074e82 in java_complete_tree (node=0x400550a8) at parse.y:11433
#10 0x08075529 in java_complete_lhs (node=0x4004c560) at parse.y:11825
#11 0x08074e82 in java_complete_tree (node=0x4004c560) at parse.y:11433
#12 0x08078801 in java_complete_lhs (node=0x400b12c0) at parse.y:11552
#13 0x08074e82 in java_complete_tree (node=0x400b12c0) at parse.y:11433
#14 0x08078801 in java_complete_lhs (node=0x400b5160) at parse.y:11552
#15 0x08074e82 in java_complete_tree (node=0x400b5160) at parse.y:11433
#16 0x080671f7 in java_complete_expand_method (mdecl=0x400b3c3c) at 
parse.y:7948
#17 0x080661cd in java_complete_expand_methods (class_decl=0x40078af8) at 
parse.y:7615
#18 0x08065e2f in java_complete_expand_class (outer=0x40078af8) at parse.y:7579
#19 0x08065d5d in java_complete_expand_classes () at parse.y:7558
#20 0x0806aad9 in java_expand_classes () at parse.y:8878
#21 0x080be562 in java_parse_file (set_yydebug=0) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/java/jcf-parse.c:1119
#22 0x08300c6a in compile_file () at /home/gates/pinskia/src/gnu/gcc/src/gcc/
toplev.c:2207
#23 0x08306da8 in do_compile () at /home/gates/pinskia/src/gnu/gcc/src/gcc/
toplev.c:5732
#24 0x08306e19 in toplev_main (argc=33, argv=0x0) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/toplev.c:5761
#25 0x080d9a4b in main (argc=33, argv=0x21) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/main.c:37
(gdb) shell gcj -v
Reading specs from /home/gates/pinskia/linux/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Reading specs from /home/gates/pinskia/linux/lib/gcc-lib/i686-pc-linux-gnu/3.4/../../../
libgcj.spec
rename spec lib to liborig
Configured with: /home/gates/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-
gnu --enable-__cxa_atexit --prefix=/home/gates/pinskia/linux --enable-threads=posix --
enable-shared
Thread model: posix
gcc version 3.4 20030602 (experimental)
(gdb) l
37        return toplev_main (argc, argv);
38      }
(gdb) l  parse.y:9692
9687              if (not_accessible_p (TREE_TYPE (decl), decl, type, 0))
9688                {
9689                  parse_error_context
9690                    (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
9691                     java_accstring_lookup (get_access_flags_from_decl (decl)),
9692                     GET_TYPE_NAME (type),
9693                     IDENTIFIER_POINTER (DECL_NAME (decl)),
9694                     IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9695                  return 1;
9696                }
(gdb) p type
$1 = 0x0
Comment 3 Andrew Pinski 2003-07-05 03:18:22 UTC
Still happens on the mainline (20030704).
Comment 4 Andrew Pinski 2004-01-08 08:34:04 UTC
Related to bug 5135.
Comment 5 Andrew Pinski 2004-05-21 02:43:06 UTC
The ICE is gone on the mainline but it is rejected unless you compile P/a.java and P/
b.java to *.class files.

./P/b.java:3: error: Can't access class `P.a'. Only public classes and interfaces in other 
packages can be accessed.
   public interface b { static int B = a.A; }
                                       ^
./P/b.java:3: error: Can't access package-private field `P.a.A' from `Q.c'.
   public interface b { static int B = a.A; }
                                        ^
2 errors
Comment 6 Tom Tromey 2007-01-09 20:45:32 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.