public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: snyder@fnal.gov
To: gcc-gnats@gcc.gnu.org
Subject: target/6087: 3.1 i86 FP stack pop bug
Date: Thu, 28 Mar 2002 16:16:00 -0000	[thread overview]
Message-ID: <200203290008.g2T08t305925@karma.fnal.gov> (raw)


>Number:         6087
>Category:       target
>Synopsis:       3.1 i86 FP stack pop bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 28 16:16:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        3.1 20020326 (prerelease)
>Organization:
>Environment:
System: Linux karma 2.4.9-13 #1 Tue Oct 30 20:11:04 EST 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../egcs/configure --prefix=/usr/local/egcs --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77
>Description:

The code below executes incorrectly.
Here's what i get:

$ g++ -O0 -o x x.cc y.cc
$ ./x
25.000000
25.000000
25.000000
25.000000
nan
nan

What's happening is that the CftRibbon() constructor
is not properly popping the result of foobar5() off the FP stack.
The stack eventually fills up, and we start getting nan's resulting
from FP operations.

Here's the generated code for the call to foobar5():

.LEHB0:
        call    _Z7foobar5v
.LEHE0:
        fld     %st(0)
        jmp     .L1


Instead of popping the returned value, this duplicates it.


>How-To-Repeat:

Compile and link together these two sources.

-- x.cc ----------------------------------------------------------
struct d0om_Registerable
{
  virtual ~d0om_Registerable () {}
};

struct CftRibbon : public d0om_Registerable
{
  CftRibbon ();
};
 
double foobar5 ();

CftRibbon::CftRibbon ()
{
  foobar5();
}


int main ()
{
  new CftRibbon;
  new CftRibbon;
  new CftRibbon;
  new CftRibbon;
  new CftRibbon;
  new CftRibbon;
  return 0;
}
-- y.cc ----------------------------------------------------------
extern "C" int printf(...);
double x = 3;
double y = 4;
double foobar5 ()
{
  double z = x*x+y*y;
  printf ("%lf\n", z);
  return z;
}

------------------------------------------------------------------

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-03-29  0:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-28 16:16 snyder [this message]
2002-03-28 19:41 rth
2002-03-28 22:23 rth

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

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

  git send-email \
    --in-reply-to=200203290008.g2T08t305925@karma.fnal.gov \
    --to=snyder@fnal.gov \
    --cc=gcc-gnats@gcc.gnu.org \
    /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).