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]

EH bug: throw eats stack memory with -O3 on x86


Hi,

The following program, when compiled with g++ 2.95.1 on Linux/x86 with "-O3",
eats a growing amount of stack memory (run "top" while it runs), and finally
segfaults when it reaches the default 8MB stacksize.
The same happens with the current CVS, but only when I uncomment "throw (int)"
in the first line below.

--------------------------------
void f() // throw (int)
{
  throw int();
}

int main()
{
  for (int i=0; i<1000000; i++)
  {
    try 
    {
      f();
    }
    catch (int) {}
  }
  return 0;
}
--------------------------------

I use Binutils 2.9.1.0.15 (so according to the FAQ, it's not the problem).

There doesn't seem to be any such problems on Sparc/SunOS.


This program runs nearly twice as fast with -O3 than with -O2.
It's also 3 times faster when "throw (int)" is not specified in the
prototype of f().
Moreover, the current GCC appears to be slower than 2.95.1.

Are there plans to speed up this throw/catch handling in the future ?

-- 
Sylvain

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