| 1 |
/* { dg-do run { target c++11 } } */ |
| 2 |
/* { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } } */ |
| 3 |
/* There is a devirtualizable call. In PR60306 we deduced wrong target to cxa_pure_virtual. |
| 4 |
For gcc 4.10 we temporarily disable the devirtualization. */ |
| 5 |
/* { dg-options "-O3" } */ |
| 6 |
|
| 7 |
#include <vector> |
| 8 |
|
| 9 |
using std::vector; |
| 10 |
|
| 11 |
class Object |
| 12 |
{ |
| 13 |
public: |
| 14 |
|
| 15 |
virtual Object* clone() const =0; |
| 16 |
|
| 17 |
virtual int type() const {return 0;} |
| 18 |
|
| 19 |
Object& operator=(const Object&) {return *this;} |
| 20 |
|
| 21 |
Object() {} |
| 22 |
Object(const Object&) {} |
| 23 |
virtual ~Object() {} |
| 24 |
}; |
| 25 |
|
| 26 |
Object* f(const Object&o) |
| 27 |
{ |
| 28 |
return o.clone(); |
| 29 |
} |
| 30 |
|
| 31 |
template<typename T> |
| 32 |
class Box: public Object, public T |
| 33 |
{ |
| 34 |
public: |
| 35 |
Box<T>* clone() const {return new Box<T>(*this);} |
| 36 |
|
| 37 |
Box<T>& operator=(const Box<T>& t) |
| 38 |
{ |
| 39 |
T::operator=(t); |
| 40 |
return *this; |
| 41 |
} |
| 42 |
|
| 43 |
Box<T>& operator=(const T& t) |
| 44 |
{ |
| 45 |
T::operator=(t); |
| 46 |
return *this; |
| 47 |
} |
| 48 |
|
| 49 |
Box() = default; |
| 50 |
Box(const Box<T>&) = default; |
| 51 |
explicit Box(const T& t):T(t) {} |
| 52 |
}; |
| 53 |
|
| 54 |
template <typename T> |
| 55 |
using Vector = Box<vector<T>>; |
| 56 |
|
| 57 |
typedef Vector<int> OVector; |
| 58 |
|
| 59 |
OVector edges_connecting_to_node(int n) |
| 60 |
{ |
| 61 |
OVector branch_list_; |
| 62 |
for(int i=0;i<n;i++) |
| 63 |
branch_list_.push_back(i); |
| 64 |
|
| 65 |
return branch_list_; |
| 66 |
} |
| 67 |
|
| 68 |
int main(int argc,char* argv[]) |
| 69 |
{ |
| 70 |
for(int n=0; n < argc; n++) |
| 71 |
{ |
| 72 |
auto x = edges_connecting_to_node(1); |
| 73 |
x.clone(); |
| 74 |
f(x); |
| 75 |
} |
| 76 |
} |