1// { dg-do run } 2 3// Copyright (C) 2000 Free Software Foundation, Inc. 4// Contributed by Nathan Sidwell 8 Mar 2000 <nathan@codesourcery.com> 5 6// Derived from PR#7 7 8// We need to destroy the thrown object when exiting the catch 9// clause. That needs to destroy the original thrown object, not 10// the caught one (which might be a base). 11 12static int ok = 0; 13 14struct A 15{ 16 A (){} 17 virtual ~A () {} 18}; 19 20struct B : virtual A 21{ 22 int value; 23 B () 24 :value(10) 25 {} 26 ~B() 27 { 28 if (value == 10) 29 ok = 1; 30 } 31}; 32 33int main() 34{ 35 try { 36 throw B (); 37 } catch (A & e) { 38 } 39 return !ok; 40} 41