gcc/testsuite/g++.dg/opt/pr103989.C
raw| 1 | // { dg-require-effective-target c++17 } |
| 2 | // { dg-options "-Og -Wall" } |
| 3 | // { dg-skip-if "requires hosted libstdc++ for memory shared_ptr" { ! hostedlib } } |
| 4 | |
| 5 | #include <optional> |
| 6 | #include <memory> |
| 7 | |
| 8 | struct A { |
| 9 | A (int a) : a {a} |
| 10 | {} |
| 11 | |
| 12 | const std::shared_ptr <int> x; |
| 13 | int a; |
| 14 | }; |
| 15 | |
| 16 | class B |
| 17 | { |
| 18 | public: |
| 19 | B (const std::optional <A>& a) |
| 20 | : a {a} |
| 21 | { |
| 22 | } |
| 23 | public: |
| 24 | const std::optional <A> a; |
| 25 | }; |
| 26 | |
| 27 | int |
| 28 | main () |
| 29 | { |
| 30 | B b {std::nullopt}; |
| 31 | } |