Fix all tests that fail with -sanitize=return.
[official-gcc.git] / gcc / testsuite / g++.dg / overload / addr1.C
blob4eb9e2f31ca6e5750e92c1815697373736ca339b
1 // { dg-do run }
3 // Copyright (C) 2003 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 6 Sep 2003 <nathan@codesourcery.com>
5 // Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
7 // PR c++/11788 we failed to instantiate a decl, and we lost some side
8 // effects
10 static int flag = 0;
12 template <typename> struct A
14   A &active () { flag++; static A a; return a; }
15   
16   static void foo() {}
18   static void bar () {}
19   static void bar (int) {}
21   int m;
24 void (*baz ()) ()
26     A<int> a;
27     return &a.active ().foo;
30 void (*boz ()) ()
32     A<int> a;
33     return &a.active ().bar;
36 int *buz ()
38   A<int> a;
39   
40   return &a.active ().m;
43 int main ()
45   baz ();
46   boz ();
47   buz ();
48   
49   return flag != 3;