| 1 | // { dg-do run { target c++11 } } |
| 2 | |
| 3 | // Bug libstdc++/116529 - Construction of unique_ptr with reference type |
| 4 | // is rejected because of auto_ptr constructor |
| 5 | |
| 6 | #include <memory> |
| 7 | #include <testsuite_hooks.h> |
| 8 | |
| 9 | int count = 0; |
| 10 | |
| 11 | struct X |
| 12 | { |
| 13 | ~X() { ++count; } |
| 14 | }; |
| 15 | |
| 16 | struct deleter : std::default_delete<X> |
| 17 | { |
| 18 | using pointer = X*; |
| 19 | }; |
| 20 | |
| 21 | void |
| 22 | test01() |
| 23 | { |
| 24 | { |
| 25 | std::unique_ptr<X&, deleter> up(new X); |
| 26 | // { dg-bogus "forming pointer to reference" "" { target *-*-* } 0 } |
| 27 | VERIFY( count == 0 ); |
| 28 | } |
| 29 | VERIFY( count == 1 ); |
| 30 | } |
| 31 | |
| 32 | int main() |
| 33 | { |
| 34 | test01(); |
| 35 | } |