unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "Ralf Wildenhues" <Ralf.Wildenhues@gmx.de>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: bug-guile <bug-guile@gnu.org>, bug-autoconf@gnu.org
Subject: Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA
Date: Mon, 20 Jun 2011 08:35:12 +0200	[thread overview]
Message-ID: <20110620063512.10360@gmx.net> (raw)
In-Reply-To: <4DFEDC29.1040201@cs.ucla.edu>

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	other threads:[~2011-06-20  6:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17 10:21 bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA Andy Wingo
2011-06-18 20:25 ` Andrew W. Nosenko
2011-06-19 19:03   ` Andy Wingo
2011-06-20  8:25     ` Andrew W. Nosenko
2011-06-20 10:24       ` Andrew W. Nosenko
2011-06-18 21:42 ` Paul Eggert
2011-06-19 19:01   ` Andy Wingo
2011-06-20  5:35     ` Paul Eggert
2011-06-20  6:35       ` Ralf Wildenhues [this message]
2011-06-20  6:50         ` Paul Eggert
2011-06-20  8:18           ` Andrew W. Nosenko
2011-06-20  8:01       ` Andy Wingo
2011-06-20 17:54       ` Eric Blake
2011-06-20 22:19         ` Paul Eggert
2011-06-21 19:43           ` Ralf Wildenhues
2011-06-21 20:08             ` Paul Eggert
2011-06-20 17:56 ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110620063512.10360@gmx.net \
    --to=ralf.wildenhues@gmx.de \
    --cc=bug-autoconf@gnu.org \
    --cc=bug-guile@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).