This is the mail archive of the gcc-patches@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]

[patch] C++ -fno-rtti regression on sparc-sun-solaris2.[75]


The following C++ source produces an ICE on sparc-sun-solaris2.[75]
when compiled with the latest gcc 2.95 snapshot.  It prevents GNU
octave from building on Solaris/sparc.  In fact, this code snippet is
a stripped/renamed version of one of the source files that gcc failed
to compile.

foo.ii


oliva@tigre% eg++ -v
Reading specs from /n/temp1/gcctest/egcs/sun4-SunOS-5.7/lib/gcc-lib/sparc-sun-solaris2.7/gcc-2.95/specs
gcc version gcc-2.95 19990629 (prerelease)
oliva@tigre% eg++ -c test.ii
oliva@tigre% eg++ -c test.ii -fno-rtti
In file included from foo.cc:2:
foo.h:2: Internal compiler error.
foo.h:2: Please submit a full bug report to `egcs-bugs@egcs.cygnus.com'.
foo.h:2: See <URL:http://egcs.cygnus.com/faq.html#bugreport> for details.
oliva@tigre% eg++ -c test.ii -fno-rtti -fvtable-thunks
oliva@tigre% eg++ -c test.ii -fno-rtti -fno-vtable-thunks
In file included from foo.cc:2:
foo.h:2: Internal compiler error.
foo.h:2: Please submit a full bug report to `egcs-bugs@egcs.cygnus.com'.
foo.h:2: See <URL:http://egcs.cygnus.com/faq.html#bugreport> for details.

cc1plus crashes in mark_vtable_entries() (cp/decl2.c:2420).  The weird 
thing is that `fn' seems to be an integer constant, not a function,
which I get when I run with -frtti.  -fvtable-thunks also works around 
the problem.

The code goes like this.  

      if (TREE_CODE (TREE_VALUE (entries)) == NOP_EXPR)
	/* RTTI offset.  */
	continue;

In the first iteration of the loop around this snippet, this test
should succeed, so as to skip the RTTI offset, but it doesn't.

      fnaddr = (flag_vtable_thunks ? TREE_VALUE (entries) 
		: FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries)));

But at this point, fnaddr *is* a nop_expr, because flag_vtable_thunks
was zero, so FNADDR_FROM_VTABLE_ENTRY was used.

      fn = TREE_OPERAND (fnaddr, 0);

And fn is an integer_cst, so it's reasonable that the code below
crashes:

      TREE_ADDRESSABLE (fn) = 1;
(*)   if (DECL_LANG_SPECIFIC (fn) && DECL_ABSTRACT_VIRTUAL_P (fn))


It seems to me that either the RTTI offset test should take care of
the -fno-vtable-thunks case or whatever generates these entries should 
arrange that the RTTI offset passes the test above.  What I don't
understand is why the same program compiles successfully on other
platforms, with all combinations of -f[no-]rtti and
-f[no-]vtable-thunks...  Does anybody?

The attached patch seems to work around this particular ICE, but I'm
not sure it does the right thing on all cases (I haven't got to the
testsuite yet).

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists
Index: gcc/cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.216.4.2
diff -u -c -r1.216.4.2 decl2.c
*** gcc/cp/decl2.c	1999/06/16 17:49:57	1.216.4.2
--- gcc/cp/decl2.c	1999/07/05 10:28:22
***************
*** 2409,2420 ****
        tree fnaddr;
        tree fn;
  
!       if (TREE_CODE (TREE_VALUE (entries)) == NOP_EXPR)
  	/* RTTI offset.  */
  	continue;
  
-       fnaddr = (flag_vtable_thunks ? TREE_VALUE (entries) 
- 		: FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries)));
        fn = TREE_OPERAND (fnaddr, 0);
        TREE_ADDRESSABLE (fn) = 1;
        if (DECL_LANG_SPECIFIC (fn) && DECL_ABSTRACT_VIRTUAL_P (fn))
--- 2409,2421 ----
        tree fnaddr;
        tree fn;
  
!       fnaddr = (flag_vtable_thunks ? TREE_VALUE (entries) 
! 		: FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries)));
! 
!       if (TREE_CODE (fnaddr) == NOP_EXPR)
  	/* RTTI offset.  */
  	continue;
  
        fn = TREE_OPERAND (fnaddr, 0);
        TREE_ADDRESSABLE (fn) = 1;
        if (DECL_LANG_SPECIFIC (fn) && DECL_ABSTRACT_VIRTUAL_P (fn))

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