comparison gcc/testsuite/g++.dg/cpp1z/inh-ctor38.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 // { dg-do run { target c++11 } } 1 // { dg-do run { target c++11 } }
2 // PR78495 failed to propagate pass-by-value struct to base ctor. 2 // PR78495 failed to propagate pass-by-value struct to base ctor.
3
4 static int moves = 0;
3 5
4 struct Ptr { 6 struct Ptr {
5 void *ptr = 0; 7 void *ptr = 0;
6 8
7 Ptr() {} 9 Ptr() {}
8 Ptr(Ptr const&) = delete; 10 Ptr(Ptr const&) = delete;
9 Ptr(Ptr&& other) : ptr (other.ptr) {} 11 Ptr(Ptr&& other) : ptr (other.ptr) {moves++;}
10 }; 12 };
11 13
12 struct Base { 14 struct Base {
13 Ptr val; 15 Ptr val;
14 Base(Ptr val_) : val(static_cast<Ptr&&>(val_)) {} 16 Base(Ptr val_);
15 }; 17 };
16 18
17 struct Derived: Base { 19 struct Derived: Base {
18 using Base::Base; 20 using Base::Base;
19 }; 21 };
25 27
26 return d.val.ptr; 28 return d.val.ptr;
27 } 29 }
28 30
29 int main () { 31 int main () {
30 return Foo () != 0; 32 if (Foo ())
33 return 1;
34
35 if (moves != 2)
36 return 2;
37
38 return 0;
31 } 39 }
40
41 Base::Base(Ptr val_) : val(static_cast<Ptr&&>(val_)) {}