summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/torture/pr40834.C
blob: 67d3028532a035a5f011303c58f510e860963de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* { dg-do run } */

extern "C" void abort (void);
class XalanDOMString
{
public:
  int y;
};

class XObject
{
public:
  const XalanDOMString& str() const { return x; }
  XalanDOMString x;
};

class XObjectPtr
{
public:
  XObjectPtr(const XObjectPtr& theSource)
    {
      m_xobjectPtr = theSource.m_xobjectPtr;
    }
  const XObject* operator->() const
    {
      return m_xobjectPtr;
    };
  XObjectPtr(XObject *p) { m_xobjectPtr = p; }
  XObject* m_xobjectPtr;
};

class FunctionSubstringBefore
{
public:
  int execute( const XObjectPtr arg1) const
    {
      const XalanDOMString& theFirstString = arg1->str();
      return theFirstString.y;
    }
};

int
main ()
{
  XObject x; 
  XObjectPtr y (&x);
  x.x.y = -1;
  FunctionSubstringBefore z;
  if (z.execute (y) != -1)
    abort ();
  return 0;
}