c++: goto entering scope of obj w/ non-trivial dtor [PR103091]
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / init9.C
blob0194cd1b49a9474ab2e824540787e3351336bb60
1 // { dg-do assemble  }
3 // Based on a testcase submitted by Tudor Hulubei <tudor@cs.unh.edu>
5 // X is not a POD because it has a user-defined destructor.
6 // Therefore, we can't cross its initialization.
8 // vector<int> is not even an aggregate; nevertheless, no error is
9 // reported...
11 struct A {
12   A() {}
15 void a() {
16   goto bar; // { dg-message "" } jump from here
17   A x; // { dg-message "" } jump crosses initialization
18  bar: // { dg-error "" } jump to here
19   ;
22 struct X {
23   ~X() {}
26 void b() {
27   // This was ill-formed until DR 2256.
28   goto bar;
29   X x;
30  bar:
31   ;
34 #include <vector>
36 void c() {
37   goto bar; // { dg-message "" } jump from here
38   std::vector<int> x; // { dg-message "" } jump crosses initialization
39  bar: // { dg-error "" } jump to here
40   ;