From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Andrew W. Nosenko" Newsgroups: gmane.lisp.guile.bugs,gmane.comp.sysutils.autoconf.bugs Subject: Re: bug in check for stack growth direction in _AC_LIBOBJ_ALLOCA Date: Mon, 20 Jun 2011 13:24:31 +0300 Message-ID: References: <87d3ic92sc.fsf@pobox.com> <87k4chod7y.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1308565507 968 80.91.229.12 (20 Jun 2011 10:25:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2011 10:25:07 +0000 (UTC) Cc: bug-guile , bug-autoconf@gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Jun 20 12:25:03 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QYbfC-0008Gr-Vf for guile-bugs@m.gmane.org; Mon, 20 Jun 2011 12:25:03 +0200 Original-Received: from localhost ([::1]:54705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYbfB-0003V5-HA for guile-bugs@m.gmane.org; Mon, 20 Jun 2011 06:25:01 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYben-0003TU-VW for bug-guile@gnu.org; Mon, 20 Jun 2011 06:24:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYbem-0002RU-Og for bug-guile@gnu.org; Mon, 20 Jun 2011 06:24:37 -0400 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:38580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYbei-0002Qh-JX; Mon, 20 Jun 2011 06:24:33 -0400 Original-Received: by fxm18 with SMTP id 18so883948fxm.0 for ; Mon, 20 Jun 2011 03:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jylF1+gM4Rb2sw2TaBhro37Mz0lmflbWILMb5jmHxLE=; b=IeNheLRq2CnSDRXXL99PNCriO8ewUP4Ssc5DGvH5PbZUSDB12HkHiTkZjzhkZcdqp6 USxtpqfm/Zq93Oua/GncB+i1CNKADWfNXlwjvuPoOZTgVJjjxD34O0hLm8BSZm5hz4IN me7MwQoFv9qCOWVVd3n8bAG4eObJzdjHWtdL8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=srCrN30wriWjvLHpBeN+d2hSFvnfc93xyRUUpMJ+AzQkiiiM1ZzhxKH4OAM1zhUaUj QXxGqx5yGohvDqdhyraoQe9gmv28X8JtqBEi8qRw/cIKsDTBRV6IXVu5oTzkkIJjWd91 Fd0otvFsl7zAwsTTfK71Pl0upV3+6DtzgcSqM= Original-Received: by 10.223.86.200 with SMTP id t8mr1245229fal.54.1308565471527; Mon, 20 Jun 2011 03:24:31 -0700 (PDT) Original-Received: by 10.223.103.4 with HTTP; Mon, 20 Jun 2011 03:24:31 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.41 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5681 gmane.comp.sysutils.autoconf.bugs:7957 Archived-At: 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: >>>> =A0wingo@badger:/tmp$ cat foo.c >>>> =A0int >>>> =A0find_stack_direction () >>>> =A0{ >>>> =A0 =A0static char *addr =3D 0; >>> >>> Try to rewrite this line as >>> =A0 =A0 =A0 =A0 volatile static char *addr =3D 0; >>> It should help. >> >> It didn't, unfortunately. > > You are right. =A0I marked the underlying char as volatile instead of > the pointer itself. > The proper version seems > =A0 =A0static char* volatile addr; > but ATM I have no compiler around for verify that. > The static char* volatile addr; doesn't help also. Gcc continues to think that it has rights to inline the inner find_stack_direction() and messes the check as consequence. Solution: make Gcc unable to inline the function call. One of possible ways to achieve it: call the inner through volatile pointer= . typedef int (*func_t)(); int find_stack_direction (); volatile func_t f =3D &find_stack_direction; int find_stack_direction () { static char *addr =3D 0; auto char dummy; if (addr =3D=3D 0) { addr =3D &dummy; return f(); } else return (&dummy > addr) ? 1 : -1; } int main () { int r =3D find_stack_direction (); return r < 0; } It's not the single way, but just first that come to minds. --=20 Andrew W. Nosenko