diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2017-05-16 14:54:16 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2017-05-16 12:54:16 +0000 |
commit | 2c27a627a31034165af6c01e07a69d867010fbbd (patch) | |
tree | 4dbdb0b7f129e5b9df2321eb95875e368a5e7e23 | |
parent | 322763f5df41223003720e8333c011b953bc1b4f (diff) | |
download | gcc-2c27a627a31034165af6c01e07a69d867010fbbd.zip gcc-2c27a627a31034165af6c01e07a69d867010fbbd.tar.gz gcc-2c27a627a31034165af6c01e07a69d867010fbbd.tar.bz2 |
optional (_Optional_base::_M_get): Check precondition.
2017-05-16 Marc Glisse <marc.glisse@inria.fr>
* include/std/optional (_Optional_base::_M_get): Check precondition.
* testsuite/20_util/optional/cons/value_neg.cc: Update line numbers.
From-SVN: r248099
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/std/optional | 10 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc | 6 |
3 files changed, 16 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f228a39..0fea52b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2017-05-16 Marc Glisse <marc.glisse@inria.fr> + + * include/std/optional (_Optional_base::_M_get): Check precondition. + * testsuite/20_util/optional/cons/value_neg.cc: Update line numbers. + 2017-05-16 Jonathan Wakely <jwakely@redhat.com> * doc/xml/manual/appendix_contributing.xml: Link to test docs and diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 5aa926f..c697c16 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -386,11 +386,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // The _M_get operations have _M_engaged as a precondition. constexpr _Tp& _M_get() noexcept - { return this->_M_payload._M_payload; } + { + __glibcxx_assert(_M_is_engaged()); + return this->_M_payload._M_payload; + } constexpr const _Tp& _M_get() const noexcept - { return this->_M_payload._M_payload; } + { + __glibcxx_assert(_M_is_engaged()); + return this->_M_payload._M_payload; + } // The _M_construct operation has !_M_engaged as a precondition // while _M_destruct has _M_engaged as a precondition. diff --git a/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc b/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc index 5abe26e..524e302 100644 --- a/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc +++ b/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc @@ -37,8 +37,8 @@ int main() std::optional<std::unique_ptr<int>> oup2 = new int; // { dg-error "conversion" } struct U { explicit U(std::in_place_t); }; std::optional<U> ou(std::in_place); // { dg-error "no matching" } - // { dg-error "no type" "" { target { *-*-* } } 487 } - // { dg-error "no type" "" { target { *-*-* } } 497 } - // { dg-error "no type" "" { target { *-*-* } } 554 } + // { dg-error "no type" "" { target { *-*-* } } 493 } + // { dg-error "no type" "" { target { *-*-* } } 503 } + // { dg-error "no type" "" { target { *-*-* } } 560 } } } |