exception in 'return (cast)expression' on Linux

Alexander Schiemann aschiem@count.math.uni-sb.de
Tue Jan 5 08:36:00 GMT 1999


Dear GNUs


bug of egcs-1.1.1 on linux:
an exception in a `return cast_expression' cannot be caught in the
following context if compiled *without optimization*. On HP-UX the
same example works (with the same compiler version). 

best regards
Alexander Schiemann


<begin example>
#include <iostream.h>

struct A_data{};

struct B_data:A_data{};

struct A{
  A_data *P;

  const A_data& obj()const
  {throw 3;
  return *P;}
};

struct B{
  A a;
  
  const B_data& obj()const
  {return (const B_data&)a.obj();}  // will throw 3
};


int main()
{B b;

try{
  cout<<"triggering exception"<<endl;
  b.obj();
}
catch(...)
  {cout<<"... caught"<<endl;}
}
<end example>

<start emacs-shell>
-> g++-egcs-1.1.1 -v
Reading specs from /usr/local/egcs-1.1.1/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.91.60/specs
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
-> g++-egcs-1.1.1 -static -fexceptions -Wall -g throw_in_cast_expr.cc 
-> a.out
triggering exception
Segmentation fault
-> g++-egcs-1.1.1 -static -fexceptions -Wall -g -O1 throw_in_cast_expr.cc 
-> a.out
triggering exception
... caught
<end emacs-shell>

hardware (pentium II 400Mhz):
MACHINE=i686
MACHTYPE=i586-pc-linux-gnu
OSTYPE=linux-gnu

configuration of egcs-1.1.1:
#!/bin/sh
# This file was generated automatically by configure.  Do not edit.
# This directory was configured as follows:
../egcs-1.1.1/configure --with-gcc-version-trigger=/tmp/EGCS/egcs-1.1.1/gcc/version.c --host=i686-pc-linux-gnulibc1 --prefix=/usr/local/egcs-1.1.1 --enable-shared --enable-version-specific-runtime-libs --norecursion 
# using "mh-frag" and "mt-frag"




More information about the Gcc-bugs mailing list