bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

G++ 2.95.2 optimizer bug


From: Christopher Neufeld
Subject: G++ 2.95.2 optimizer bug
Date: Thu, 24 May 2001 19:22:03 -0400

I have located a bug in the way code is generated for throw/catch
operations in g++ 2.95.2 when optimizations are enabled.  A short test
program to demonstrate this is included:

#include <stdio.h>
 
int main(void)
{
        void *stack;
 
        while (1) {
                try {
                        throw (1);
                }
                catch ( ... ) {
 
                }
 
                asm (   "mov %%esp,%0   \n"
                        : : "m" (stack));
                printf("Stack= %p\n", stack);
 
        }
}


If this code is compiled:
g++ sample.cc -o sample

and executed, it prints out lines like:

...
Stack= 0xbffff6dc
Stack= 0xbffff6dc
Stack= 0xbffff6dc
Stack= 0xbffff6dc
Stack= 0xbffff6dc
Stack= 0xbffff6dc
Stack= 0xbffff6dc
...

If compiled:
g++ -O sample.cc -o sample

and executed, it prints out lines like:

...
Stack= 0xbfff058c
Stack= 0xbfff057c
Stack= 0xbfff056c
Stack= 0xbfff055c
Stack= 0xbfff054c
Stack= 0xbfff053c
Stack= 0xbfff052c
...

Losing 16 bytes of stack on every pass through the loop, until eventually
it runs out of stack space.  

This bug was revealed in real code.

-- 
Christopher Neufeld, Senior Linux Consultant, Linuxcare, Inc.
613.562.9854 tel, 613.562.9304 fax
address@hidden, http://www.linuxcare.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]