Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-21 Thread Paul Eggert
On 06/21/11 12:43, Ralf Wildenhues wrote: > It would be good to make sure GCC 4.6 whole program/link time > optimization doesn't defeat this It doesn't, at least, not on my platform (Fedora 14 x86-64 + GCC 4.6.0).

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-21 Thread Ralf Wildenhues
* Paul Eggert wrote on Tue, Jun 21, 2011 at 12:19:25AM CEST: > Testing this is not something for the fainthearted, as it requires > access to all sorts of strange hosts. However, it does seem to > defeat GCC 4.6.0's tail-recursion optimization (-O0 through -O4) > on my platform, which is what is w

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Paul Eggert
On 06/20/11 10:54, Eric Blake wrote: > Hmm, we'll need to backport this improved stack-direction testing to > gnulib and libsigsegv, then, Makes sense. I just pushed this gnulib patch, to do that part. Testing this is not something for the fainthearted, as it requires access to all sorts of str

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Eric Blake
On 06/17/2011 04:21 AM, Andy Wingo wrote: > wingo@badger:/tmp$ gcc -O1 -o test foo.c > wingo@badger:/tmp$ ./test; echo $? > 1 > wingo@badger:/tmp$ gcc -O3 -o test foo.c > wingo@badger:/tmp$ ./test; echo $? > 0 If I understand correctly, 0 is a correct result, just not optimal. Improve

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Eric Blake
[adding bug-gnulib] On 06/19/2011 11:35 PM, Paul Eggert wrote: > On 06/19/11 12:01, Andy Wingo wrote: >> No, this program also exhibits the same incorrect behavior, for purposes >> of stack growth checking. > > Thanks, I guess we'll have to turn it up a notch. How about the > following test prog

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Andrew W. Nosenko
On Mon, Jun 20, 2011 at 11:25, Andrew W. Nosenko wrote: > On Sun, Jun 19, 2011 at 22:03, Andy Wingo wrote: >> Hi, >> >> On Sat 18 Jun 2011 22:25, "Andrew W. Nosenko" >> writes: >> >>> On Fri, Jun 17, 2011 at 13:21, Andy Wingo wrote:  wingo@badger:/tmp$ cat foo.c  int  find_stack

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Andrew W. Nosenko
On Sun, Jun 19, 2011 at 22:03, Andy Wingo wrote: > Hi, > > On Sat 18 Jun 2011 22:25, "Andrew W. Nosenko" > writes: > >> On Fri, Jun 17, 2011 at 13:21, Andy Wingo wrote: >>>  wingo@badger:/tmp$ cat foo.c >>>  int >>>  find_stack_direction () >>>  { >>>    static char *addr = 0; >> >> Try to rewr

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Andrew W. Nosenko
On Mon, Jun 20, 2011 at 09:50, Paul Eggert wrote: > On 06/19/11 23:35, Ralf Wildenhues wrote: >> If you don't use volatile, the compiler is pretty much free to give you >> whatever answer it likes today. > > It's true that the test relies on undefined behavior, and so the > compiler is free to do

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-20 Thread Andy Wingo
On Mon 20 Jun 2011 07:35, Paul Eggert writes: > On 06/19/11 12:01, Andy Wingo wrote: >> No, this program also exhibits the same incorrect behavior, for purposes >> of stack growth checking. > > Thanks, I guess we'll have to turn it up a notch. How about the > following test program? Works for m

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Paul Eggert
On 06/19/11 23:35, Ralf Wildenhues wrote: > If you don't use volatile, the compiler is pretty much free to give you > whatever answer it likes today. It's true that the test relies on undefined behavior, and so the compiler is free to do whatever it wants, but I don't see how adding "volatile" hel

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Ralf Wildenhues
Hello Paul, * Paul Eggert wrote on Mon, Jun 20, 2011 at 07:35:37AM CEST: > On 06/19/11 12:01, Andy Wingo wrote: > > No, this program also exhibits the same incorrect behavior, for purposes > > of stack growth checking. > > Thanks, I guess we'll have to turn it up a notch. How about the > followi

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Paul Eggert
On 06/19/11 12:01, Andy Wingo wrote: > No, this program also exhibits the same incorrect behavior, for purposes > of stack growth checking. Thanks, I guess we'll have to turn it up a notch. How about the following test program? int find_stack_direction (int *addr, int depth) { int dir, dummy =

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Paul Eggert
Does it work to use the following test program instead? int find_stack_direction (char *addr) { char dummy; return (! addr ? find_stack_direction (&dummy) : addr < &dummy ? 1 : -1); } int main (void) { return find_stack_direction (0) < 0; } This, essentially, is the fix I just pu

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Andrew W. Nosenko
On Fri, Jun 17, 2011 at 13:21, Andy Wingo wrote: > Hello, > > The following transcript indicates a problem with the stack growth > direction check, present at functions.m4:328 in autoconf 2.68: > >  wingo@badger:/tmp$ cat foo.c >  int >  find_stack_direction () >  { >    static char *addr = 0; Tr

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Andy Wingo
Hi, On Sat 18 Jun 2011 22:25, "Andrew W. Nosenko" writes: > On Fri, Jun 17, 2011 at 13:21, Andy Wingo wrote: >>  wingo@badger:/tmp$ cat foo.c >>  int >>  find_stack_direction () >>  { >>    static char *addr = 0; > > Try to rewrite this line as > volatile static char *addr = 0; > It sh

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-19 Thread Andy Wingo
On Sat 18 Jun 2011 23:42, Paul Eggert writes: > Does it work to use the following test program instead? > > int > find_stack_direction (char *addr) > { > char dummy; > return (! addr ? find_stack_direction (&dummy) > : addr < &dummy ? 1 : -1); > } > > int > main (void) > { > retur

bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA

2011-06-17 Thread Andy Wingo
Hello, The following transcript indicates a problem with the stack growth direction check, present at functions.m4:328 in autoconf 2.68: wingo@badger:/tmp$ cat foo.c int find_stack_direction () { static char *addr = 0; auto char dummy; if (addr == 0) { addr = &d