From 8a0e3d8a9be432ead5d07095252c5c070b8d8dc8 Mon Sep 17 00:00:00 2001 From: Carson Radtke Date: Fri, 13 Dec 2024 10:22:16 -0600 Subject: [PATCH] fix: direct-init const ref instead of list-init (#1175) fixes: https://github.com/microsoft/GSL/issues/1162 gcc has a bug that generates a call to the copy constructor when list initializing a const reference. This PR offers a workaround which is to direct initialize the value. see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117900 --- include/gsl/pointers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index dd0f0682..594ef818 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -117,7 +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{std::declval()})) + noexcept(noexcept(details::value_or_reference_return_t(std::declval()))) { return ptr_; }