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]

[Bug c++/16219] New: Exception not caught


I know I'm not following the bug reporting guidelines. I'm afraid I can't
reproduce the bug when the program is cut down to the parts that fail. It also
goes away when I try to remove the library dependencies. I spent most of a day
removing parts of the program but it goes away. I'd like advice how I can report
this bug.

gcc -v:
Reading specs from /home/jss/devel/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --prefix=/home/jss/devel
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.0


The problem is that I throw an exception in a class in one compilation, and
catch exception in main().

int main()
{
  try{
...
}
  catch(pfits::Exception &e)
    {
      std::cerr << e() << '\n';
    }


The exception isn't caught by the catch, even though the exception class is
descended from pfits::Exception:

namespace pfits
{
  // all our exceptions derive from this one
  class Exception
  {
  public:
    Exception(const std::string& str) : _str(str) {}
    const std::string& operator() () const { return _str; }

  private:
    const std::string _str;
  };

  // thrown if fitsio reports an error
  class FITSIOError : public Exception
  {
  public:
    FITSIOError(const std::string& str)
      : Exception(str) {}
  };

}

The exception is thrown in:

namespace pfits
{
  // throw if error
  inline void check_error(_InternalFile file, const int status)
  {
    if( status != 0 )
      {
	throw FITSIOError( error_string(file, status) );
      }
  }
}

If I debug in gdb:

terminate called after throwing an instance of 'pfits::FITSIOError'
 
#0  0xffffe002 in ?? ()
#1  0x42028c55 in abort () from /lib/tls/libc.so.6
#2  0x400c7e01 in __gnu_cxx::__verbose_terminate_handler() ()
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/vterminate.cc:96
#3  0x400c59a5 in __cxxabiv1::__terminate(void (*)()) (
    handler=0x400c7d00 <__gnu_cxx::__verbose_terminate_handler()>)
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:43
#4  0x400c5882 in __gxx_personality_v0 (version=1, actions=6,
    exception_class=5138137972254386944, ue_header=0x0, context=0xbfffd8f0)
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/eh_personality.cc:434
#5  0x40129573 in _Unwind_RaiseException_Phase2 (exc=0x8178ea0,
    context=0xbfffd8f0) at unwind.inc:66
#6  0x401296e4 in _Unwind_RaiseException (exc=0x8178ea0) at unwind.inc:136
#7  0x400c5b55 in __cxa_throw (obj=0x8178ea0, tinfo=0x0, dest=0)
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/eh_throw.cc:75
#8  0x0804c36e in pfits::check_error(pfits::_InternalFile, int) (file=
      {_file = 0x8178ee0}, status=252) at privutil.hh:40
#9  0x0804c06f in pfits::File::close() (this=0xbfffdae0) at file.cc:56
#10 0x0804c01b in ~File (this=0xbfffdae0) at file.cc:45
#11 0x0804ce43 in main () at test.cc:31
#12 0x42015704 in __libc_start_main () from /lib/tls/libc.so.6


Any ideas how to debug this? Is it possible it is caused by the libraries linked
to the code? The exception doesn't pass through the library. I compiled the
program with -O0 -g -Wall (also tried -O2).

-- 
           Summary: Exception not caught
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jss at ast dot cam dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


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