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]

ICE in pre_insert_insn (gcse.c)


Hi,
I've tickled a bug in the gcse module with some simple C++ code
(a do .. while loop!). I've attached the test case (compile with -O2).
The problem is present in the 19981206 snapshot. Here's the session log,

nathan@manao:780>uname -a
SunOS manao 5.6 Generic_105181-03 sun4u sparc SUNW,Ultra-5_10
nathan@manao:781>ss-g++ -c -O2 preinsert.ii -v
Reading specs from /home/staff/nathan/solaris/local/sparc-SunOS_5/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.92.27/specs
gcc version egcs-2.92.27 19981206 (gcc2 ss-980609 experimental)
 /home/staff/nathan/solaris/local/sparc-SunOS_5/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.92.27/cc1plus preinsert.ii -quiet -O2 -version -o /var/tmp/cc2t4hAi.s
GNU C++ version egcs-2.92.27 19981206 (gcc2 ss-980609 experimental) (sparc-sun-solaris2.6) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
gcse.c:4484: Internal compiler error in function pre_insert_insn

running cc1plus under gdb, I find the following stack trace,

(gdb) run -O2 preinsert.ii
Starting program: /home/staff/nathan/egcs/egcs-ss/egcs/gcc/cc1plus -O2 preinsert.ii
Breakpoint 1 at 0x6ff3a3e8
Breakpoint 2 at 0x6ff88044
 void B::MFunc()gcse.c:4484: Internal compiler error in function pre_insert_insn

Breakpoint 2, 0x6ff88044 in exit ()
(gdb) back
#0  0x6ff88044 in exit ()
#1  0x12644c in pre_insert_insn (expr=0x2c6200, bb=0) at gcse.c:4484
#2  0x126738 in pre_insert (index_map=0xefffe8f8) at gcse.c:4578
#3  0x126ca8 in pre_gcse () at gcse.c:4807
#4  0x126d50 in one_pre_gcse_pass (f=0x0, pass=1) at gcse.c:4841
#5  0x1209f4 in gcse_main (f=0x297e48, file=0x0) at gcse.c:739
#6  0x14a94 in rest_of_compilation (decl=0x2bd9c8) at toplev.c:3698
#7  0x1a3274 in finish_function (lineno=22, call_poplevel=0, nested=0) at decl.c:13627
#8  0x1d7404 in yyparse () at parse.y:640
#9  0x132b0 in compile_file (name=0xeffff72d "preinsert.ii") at toplev.c:2900
#10 0x173c0 in main (argc=3, argv=0xeffff5d4) at toplev.c:5180

gcse.c has the following comment just before the call to abort.

      /* It should always be the case that we can put these instructions 
         anywhere in the basic block.  Check this.  */
      /* ??? Well, it would be the case if we'd split all critical edges.
         Since we didn't, we may very well abort.  */
      if (!TEST_BIT (pre_antloc[bb], expr->bitmap_index)
          && !TEST_BIT (pre_transp[bb], expr->bitmap_index))
        abort ();

Oops!

It is necessary that Baz's parameter is pass by reference and
B::MFunc has a throw() specification, in order to excite the bug.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
struct Item {};
void Fn() throw();
Item *Baz(Item *&) throw();

struct B
{
  int m;
  Item *free;                 
  void MFunc() throw();
};

void B::MFunc()
  throw()
{
  Item *msg;
  
  Fn();
  
  do
    msg = Baz(free);
  while(!msg);	 
}

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