bug-autoconf
[Top][All Lists]
Advanced

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

Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA


From: Ralf Wildenhues
Subject: Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA
Date: Mon, 20 Jun 2011 08:35:12 +0200

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
> following test program?
> 
> int
> find_stack_direction (int *addr, int depth)
> {
>   int dir, dummy = 0;
>   if (! addr)
>     addr = &dummy;
>   *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
>   dir = depth ? find_stack_direction (addr, depth - 1) : 0;
>   return dir + dummy;
> }
> 
> int
> main (int argc, char **argv)
> {
>   return find_stack_direction (0, argc + !argv + 20) < 0;
> }

If you don't use volatile, the compiler is pretty much free to give you
whatever answer it likes today.  I'm not sure whether it's required to
give the right answer with volatile, given that you're still comparing
pointers that C does not allow you to compare, but the above looks more
obfuscated than the simplest code using volatile would.

Thanks,
Ralf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]