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]

Re: missing increment bug


On Thu, Nov 30, 2000 at 09:25:19AM -0800, Ulrich Drepper wrote:
> 	http://www.cygnus.com/~drepper/l.i.gz

Minimal test case (committed as execute/20001130-1.c) is 
   
   static inline int bar(void) { return 1; }
   static int mem[3];
   
   static int foo(int x)
   {
     if (x != 0)
       return x;
   
     mem[x++] = foo(bar());
   
     if (x != 1)
       abort();
   
     return 0;
   }
   
   int main()
   {
     foo(0);
     return 0;
   }

We'd thought to emit queued insns before beginning the tail call
sequence, but not the tail recursion sequence.  The inline function
invocation is required to trigger the bug.

Fixed thus.


r~


        * calls.c (expand_call): Emit queued insns before creating
        the tail recursion sequence.

Index: calls.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/calls.c,v
retrieving revision 1.167
diff -c -p -d -r1.167 calls.c
*** calls.c	2000/11/29 00:27:54	1.167
--- calls.c	2000/11/30 20:06:15
*************** expand_call (exp, target, ignore)
*** 2552,2557 ****
--- 2552,2561 ----
        int save_pending_stack_adjust = pending_stack_adjust;
        int save_stack_pointer_delta = stack_pointer_delta;
  
+       /* Emit any queued insns now; otherwise they would end up in
+ 	 only one of the alternates.  */
+       emit_queue ();
+ 
        /* Use a new sequence to hold any RTL we generate.  We do not even
  	 know if we will use this RTL yet.  The final decision can not be
  	 made until after RTL generation for the entire function is

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