// { dg-do run }
|
// { dg-do run }
|
// { dg-options "-O2" }
|
// { dg-options "-O2" }
|
//
|
//
|
// Copyright (C) 2001 Free Software Foundation, Inc.
|
// Copyright (C) 2001 Free Software Foundation, Inc.
|
// Contributed by Nathan Sidwell 26 May 2001
|
// Contributed by Nathan Sidwell 26 May 2001
|
|
|
// Bug 2823. Inlineing the body of a thunk broke things. But that's
|
// Bug 2823. Inlineing the body of a thunk broke things. But that's
|
// rarely a sensible thing to do anyway.
|
// rarely a sensible thing to do anyway.
|
|
|
#include
|
#include
|
#include
|
#include
|
|
|
int objCount = 0;
|
int objCount = 0;
|
|
|
struct Thing
|
struct Thing
|
{
|
{
|
int count;
|
int count;
|
|
|
Thing ();
|
Thing ();
|
Thing (Thing const &src);
|
Thing (Thing const &src);
|
|
|
~Thing ();
|
~Thing ();
|
|
|
};
|
};
|
|
|
Thing::Thing ()
|
Thing::Thing ()
|
:count (0)
|
:count (0)
|
{
|
{
|
objCount++;
|
objCount++;
|
std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
|
std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
|
}
|
}
|
|
|
Thing::Thing (Thing const &src)
|
Thing::Thing (Thing const &src)
|
:count (0)
|
:count (0)
|
{
|
{
|
objCount++;
|
objCount++;
|
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
|
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
|
}
|
}
|
|
|
Thing::~Thing ()
|
Thing::~Thing ()
|
{
|
{
|
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
|
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
|
if (count)
|
if (count)
|
std::abort ();
|
std::abort ();
|
count--;
|
count--;
|
objCount--;
|
objCount--;
|
}
|
}
|
|
|
void x(Thing name)
|
void x(Thing name)
|
{
|
{
|
// destruct name here
|
// destruct name here
|
}
|
}
|
|
|
class Base
|
class Base
|
{
|
{
|
public:
|
public:
|
virtual void test(const Thing& s) = 0;
|
virtual void test(const Thing& s) = 0;
|
};
|
};
|
|
|
class Impl : virtual public Base
|
class Impl : virtual public Base
|
{
|
{
|
public:
|
public:
|
virtual void test(const Thing& s)
|
virtual void test(const Thing& s)
|
{
|
{
|
x(s); // copy construct temporary
|
x(s); // copy construct temporary
|
}
|
}
|
};
|
};
|
|
|
int main()
|
int main()
|
{
|
{
|
Impl *impl = new Impl();
|
Impl *impl = new Impl();
|
|
|
impl->test( Thing ()); // This will use a thunk
|
impl->test( Thing ()); // This will use a thunk
|
return objCount != 0;
|
return objCount != 0;
|
}
|
}
|
|
|