Bug 17220 - Incorrect ouput for C++ exceptions with -fomit-frame-pointer
Summary: Incorrect ouput for C++ exceptions with -fomit-frame-pointer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.3
: P2 normal
Target Milestone: 3.3.6
Assignee: Richard Henderson
URL:
Keywords: EH, wrong-code
Depends on:
Blocks:
 
Reported: 2004-08-28 00:47 UTC by Rennie deGraaf
Modified: 2004-12-10 03:32 UTC (History)
1 user (show)

See Also:
Host:
Target: i386-pc-linux-gnu
Build:
Known to work:
Known to fail: 4.0.0
Last reconfirmed: 2004-11-26 02:22:09


Attachments
Preprocessed source for bug 17220 (83.80 KB, application/x-bzip2)
2004-08-28 00:52 UTC, Rennie deGraaf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rennie deGraaf 2004-08-28 00:47:22 UTC
The following code compiles and executes correctly when compiled without
-fomit-frame-pointer, but aborts when compiled with -fomit-frame-pointer:

$ cat registry.cpp
#include <map>
#include <string>
#include <iostream>
using namespace std;

class Registry 
{
  public:
    Registry() : reg() {}
    ~Registry() {}
    void getFloat(string key)
    {
        map<string, float>::iterator i = reg.find(key);
        if (i == reg.end())
            throw new int(5);
    }

  protected:
    map<string, float> reg;
};

int main()
{
    Registry reg;
    string s = "four";
    
    try 
    {
        reg.getFloat(s);
    }
    catch (...)
    {
        cout << "caught one" << endl;
    }
    return 0;
}

$ g++ registry.cpp
$ ./a.out
caught one
$ g++ -fomit-frame-pointer registry.cpp
$ ./a.out
Aborted
$ 


$ g++ -v
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)

$ uname -a
Linux silmaril.renniedegraaf.homeip.net 2.6.8.1 #1 Sat Aug 21 16:32:26 MDT 2004
i686 athlon i386 GNU/Linux
Comment 1 Rennie deGraaf 2004-08-28 00:52:11 UTC
Created attachment 6997 [details]
Preprocessed source for bug 17220

Compile with -fomit-frame-pointer, and it fails.  Compile without, and it
works.
Comment 2 Andrew Pinski 2004-08-28 01:08:38 UTC
Confirmed with -march=i386 -fomit-frame-pointer so this is a target problem.
Comment 3 Richard Henderson 2004-11-26 02:26:03 UTC
I could reproduce the patch previously, but after
  http://gcc.gnu.org/ml/gcc-patches/2004-11/msg02219.html
and
  http://gcc.gnu.org/ml/gcc/2004-11/msg00912.html
I can't.

This may mean that it was a duplicate of PR6764, though I can't prove
that from the Rather Large-ish test case.
Comment 4 Andrew Pinski 2004-12-10 03:32:45 UTC
Closing as fixed as I can no longer reproduce it either but I could before.