NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: toolchain/40694: gcc tail-call vs. volatile bug

The following reply was made to PR toolchain/40694; it has been noted by GNATS.

From: David Holland <>
Subject: Re: toolchain/40694: gcc tail-call vs. volatile bug
Date: Sat, 31 Dec 2011 19:09:24 +0000

 On Thu, Feb 19, 2009 at 06:00:00PM +0000, 
  > Compiling the following fragment (gcc -O2 -S foo.c) generates an
  > invalid tail call that does not repeat the local (volatile, no less)
  > variable on a new stack frame.
  > void
  > recurse_inf(void)
  > {
  >    volatile char buf[16];
  >    buf[0] = 0;
  >    recurse_inf();
  > }
 This is not fixed in gcc 4.5. The gcc 4.5 output for i386:
         .file   "foo.c"
 .globl recurse_inf
         .type   recurse_inf, @function
         pushl   %ebp
         movl    %esp, %ebp
         subl    $16, %esp
         movb    $0, -16(%ebp)
         jmp     .L2
         .size   recurse_inf, .-recurse_inf
         .ident  "GCC: (NetBSD nb1 20110620) 4.5.3"
 and for amd64 (excluding eh_frame gunk):
         .file   "foo.c"
 .globl recurse_inf
         .type   recurse_inf, @function
         movb    $0, -24(%rsp)
         jmp     .L2
         .size   recurse_inf, .-recurse_inf
         .ident  "GCC: (NetBSD nb2 20110806) 4.5.3"
 (Why is the gcc version slightly different? I'm not sure, both
 tooldirs are pretty recent.)
  > On a plain gcc 4.1.2 configured for mips I get two byte stores per
  > loop, too, which blatantly violates the volatile rules:
 Haven't tried this with gcc 4.5.3 but I wouldn't expect it to be much
 different either.
 David A. Holland

Home | Main Index | Thread Index | Old Index