bug: cross jump optimization and exceptions

ulrich.kunitz@db.com ulrich.kunitz@db.com
Wed Aug 19 11:24:00 GMT 1998


I posted a short program on June, 1st 1998. It shows a bug in the
cross jump optimization in gcc/jump.c. The bug is in egcs 1.0.3, gcc-2.8.1
and gcc- with -O1, -O2 and -O3. I've posted a patch which
disables cross jump optimization, showing that this caused the

Now with feature freeze for egcs-1.1 I gave it another shot. I was
using egcs-19980816 aka egcs-2.91.54. The good news is that
setjump-longjump-optimization works flawless in that case. But the default case
is still broken. The -O3 optimization differs now and seems to break my example.

Please notify in the release informations that binutils-2.9.1 are
required. It took me some time to find the info in the FAQ.

Test cross jump optimization bug

gcc version: egcs-2.91.54

        -O0             -O1             -O2             -O3

noopt   ok              wrong           wrong           ok
async   ok              wrong           wrong           ok
sjlj    ok              ok              ok              ok

noopt:  gcc
async:  gcc -fasynchronous-exceptions
sjlj:   gcc -fsjlj-exceptions

I'm using glibc 1 (libc 5.4.44 on a Linux 2.0.33, S.u.S.E. 5.2,
binutils-, Pentium-MMX 166 MHz).

/* cross jump optimization bug */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

class A {
    virtual void throw_exception();
    void xxx(char * sz);

void A::throw_exception() { throw 1; }

void A::xxx(char * sz) {
    if (strcmp(sz, "xxx") == 0) {
        try {
        catch (int n) { }
    else {

int  main(void) {
    A a;
    int fOk = 1;
    try {
    catch (int n) {
        fOk = 0;
#ifdef OUTPUT
    printf(fOk != 0 ? "Ok\n" : "Wrong\n");
    exit(fOk != 0 ? 0 : 1);

If you don´t see the include files sdlib.h, stdio.h and string.h, the
Lotus email gateway of this company has erased them.

Ciao, Uli Kunitz

More information about the Gcc-bugs mailing list