This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

target/6087: 3.1 i86 FP stack pop bug



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]