111
|
1 // { dg-do assemble }
|
|
2 // { dg-options "-fexceptions" }
|
|
3 // GROUPS passed exceptions
|
|
4 // except file
|
|
5 // Message-Id: <9211301118.AA09810@ss670mp.geco.slb.com>
|
|
6 // From: willoch@ss670mp.oslo.sgp.slb.com (thorbjorn willoch)
|
|
7 // Subject: -fansi-exceptions bug
|
|
8 // Date: Mon, 30 Nov 92 11:18:05 GMT
|
|
9
|
|
10 extern "C" int printf(const char *, ...);
|
|
11
|
|
12 class Vector
|
|
13 {
|
|
14 int* p;
|
|
15 int sz;
|
|
16 public:
|
|
17 Vector(int s) { p = new int[sz=s]; }
|
|
18 ~Vector() {delete [] p; }
|
|
19 int size() {return sz; }
|
|
20 class Range{};
|
|
21
|
|
22
|
|
23 int& operator[](int i);
|
|
24 };
|
|
25
|
|
26 int& Vector::operator[](int i)
|
|
27 {
|
|
28 if(0<=i && i<sz) return p[i];
|
|
29 throw Range();
|
|
30 }
|
|
31
|
|
32 void do_something(Vector& v)
|
|
33 {
|
|
34 int i = v[v.size()+10];
|
|
35 }
|
|
36
|
131
|
37 int
|
111
|
38 main()
|
|
39 {
|
|
40 Vector v(10);
|
|
41
|
|
42 try
|
|
43 {
|
|
44 do_something(v);
|
|
45 }
|
|
46
|
|
47 catch (Vector::Range)
|
|
48 {
|
|
49 printf("Range error exception\n");
|
|
50 }
|
|
51 }
|