From 87e21400dc695e45412fb0a512c73d8d4aaa2d5b Mon Sep 17 00:00:00 2001 From: Werner Henze <34543625+beinhaerter@users.noreply.github.com> Date: Thu, 29 Jun 2023 00:17:12 +0200 Subject: [PATCH] remove gcc noexcept warning (#1122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change a `gsl::not_null` triggers these `noexcept` warnings: ``` .../gsl/include/gsl/pointers:162:50: warning: noexcept-expression evaluates to ‘false’ because of a call to ‘constexpr gsl::details::value_or_reference_return_t gsl::not_null::get() const [with T = class_type*; gsl::details::value_or_reference_return_t = class_type* const]’ [-Wnoexcept] 162 | const not_null& rhs) noexcept(noexcept(lhs.get() == rhs.get())) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../gsl/include/gsl/pointers:119:55: note: but ‘constexpr gsl::details::value_or_reference_return_t gsl::not_null::get() const [with T = class_type*; gsl::details::value_or_reference_return_t = class_type* const]’ does not throw; perhaps it should be declared ‘noexcept’ 119 | constexpr details::value_or_reference_return_t get() const | ^~~ ``` Co-authored-by: Werner Henze --- include/gsl/pointers | 1 + 1 file changed, 1 insertion(+) diff --git a/include/gsl/pointers b/include/gsl/pointers index 0759c53..6f9a193 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -117,6 +117,7 @@ public: not_null(const not_null& other) = default; not_null& operator=(const not_null& other) = default; constexpr details::value_or_reference_return_t get() const + noexcept(noexcept(details::value_or_reference_return_t{ptr_})) { return ptr_; }