From dd421f5acd9016a2f88a09150904af463ad17815 Mon Sep 17 00:00:00 2001 From: Weiming Zhao Date: Fri, 24 Jun 2016 18:02:27 +0000 Subject: [PATCH] [libcxx] guard throw with exception enabling check Summary: this fixes build error when built with c++14 and no exceptions Reviewers: rmaprath Subscribers: weimingz, grandinj, rmaprath, cfe-commits Differential Revision: http://reviews.llvm.org/D21673 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273697 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/experimental/optional | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/experimental/optional b/include/experimental/optional index a384882a1..3912438ec 100644 --- a/include/experimental/optional +++ b/include/experimental/optional @@ -517,7 +517,11 @@ public: constexpr value_type const& value() const { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else + assert(!"bad optional access"); +#endif return this->__val_; } @@ -525,7 +529,11 @@ public: value_type& value() { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else + assert(!"bad optional access"); +#endif return this->__val_; }