From 82afbfa2ee3c42bf29c656857d9c443789f32179 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Thu, 14 Jul 2022 18:11:45 +0100 Subject: [PATCH 1/9] Add BOOST_SYSTEM_CURRENT_LOCATION_PTR Allows passing current location to error_code ctor without requiring a separate static local variable. Implementation uses __builtin_source_location() on clang and gcc returning a pointer to std::source_location::__impl, which we verify is layout-compatible with boost::source_location. --- include/boost/system/detail/config.hpp | 8 ++ include/boost/system/detail/error_code.hpp | 23 ++-- .../boost/system/detail/source_location.hpp | 112 ++++++++++++++++++ test/CMakeLists.txt | 7 ++ test/Jamfile.v2 | 1 + test/ec_location_test5.cpp | 56 +++++++++ test/ec_what_test.cpp | 4 +- 7 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 include/boost/system/detail/source_location.hpp create mode 100644 test/ec_location_test5.cpp diff --git a/include/boost/system/detail/config.hpp b/include/boost/system/detail/config.hpp index ad958bcab..2ec24bfed 100644 --- a/include/boost/system/detail/config.hpp +++ b/include/boost/system/detail/config.hpp @@ -56,6 +56,14 @@ # define BOOST_SYSTEM_DEPRECATED(msg) #endif +// BOOST_SYSTEM_IMPLICIT + +#if __cplusplus >= 202002L +# define BOOST_SYSTEM_IMPLICIT explicit( false ) +#else +# define BOOST_SYSTEM_IMPLICIT +#endif + // BOOST_SYSTEM_CLANG_6 #if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11)) diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index 584b4b348..ddc974a5a 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) # include @@ -85,7 +86,7 @@ class error_code // 1: holds std::error_code in d2_ // 2: holds error code in d1_, failed == false // 3: holds error code in d1_, failed == true - // >3: pointer to source_location, failed_ in lsb + // >3: pointer to source_location or layout-compatible type, failed_ in lsb boost::uintptr_t lc_flags_; private: @@ -126,8 +127,8 @@ class error_code d1_.cat_ = &cat; } - error_code( int val, const error_category & cat, source_location const * loc ) BOOST_NOEXCEPT: - d1_(), lc_flags_( ( loc? reinterpret_cast( loc ): 2 ) | +detail::failed_impl( val, cat ) ) + BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat, detail::source_location_ptr loc ) BOOST_NOEXCEPT: + d1_(), lc_flags_( ( loc.value()? loc.value(): 2 ) | +detail::failed_impl( val, cat ) ) { d1_.val_ = val; d1_.cat_ = &cat; @@ -144,14 +145,14 @@ class error_code *this = make_error_code( e ); } - error_code( error_code const& ec, source_location const * loc ) BOOST_NOEXCEPT: + error_code( error_code const& ec, detail::source_location_ptr loc ) BOOST_NOEXCEPT: d1_(), lc_flags_( 0 ) { *this = ec; if( ec.lc_flags_ != 0 && ec.lc_flags_ != 1 ) { - lc_flags_ = ( loc? reinterpret_cast( loc ): 2 ) | ( ec.lc_flags_ & 1 ); + lc_flags_ = ( loc.value()? loc.value(): 2 ) | ( ec.lc_flags_ & 1 ); } } @@ -184,12 +185,12 @@ class error_code *this = error_code( val, cat ); } - void assign( int val, const error_category & cat, source_location const * loc ) BOOST_NOEXCEPT + void assign( int val, const error_category & cat, detail::source_location_ptr loc ) BOOST_NOEXCEPT { *this = error_code( val, cat, loc ); } - void assign( error_code const& ec, source_location const * loc ) BOOST_NOEXCEPT + void assign( error_code const& ec, detail::source_location_ptr loc ) BOOST_NOEXCEPT { *this = error_code( ec, loc ); } @@ -358,10 +359,12 @@ class error_code return lc_flags_ >= 4; } - source_location const & location() const BOOST_NOEXCEPT + source_location location() const BOOST_NOEXCEPT { - BOOST_STATIC_CONSTEXPR source_location loc; - return lc_flags_ >= 4? *reinterpret_cast( lc_flags_ &~ static_cast( 1 ) ): loc; + source_location loc; + if( lc_flags_ >= 4 ) + std::memcpy( &loc, reinterpret_cast( lc_flags_ &~ static_cast( 1 ) ), sizeof loc ); + return loc; } // relationals: diff --git a/include/boost/system/detail/source_location.hpp b/include/boost/system/detail/source_location.hpp new file mode 100644 index 000000000..3b4f37edc --- /dev/null +++ b/include/boost/system/detail/source_location.hpp @@ -0,0 +1,112 @@ +#ifndef BOOST_SYSTEM_DETAIL_SOURCE_LOCATION_HPP_INCLUDED +#define BOOST_SYSTEM_DETAIL_SOURCE_LOCATION_HPP_INCLUDED + +// Copyright Beman Dawes 2006, 2007 +// Copyright Christoper Kohlhoff 2007 +// Copyright Peter Dimov 2017-2021 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See library home page at http://www.boost.org/libs/system + +#include +#include +#include +#include + +namespace boost +{ + +namespace system +{ + +namespace detail +{ + +class source_location_ptr +{ +public: + + BOOST_SYSTEM_CONSTEXPR source_location_ptr() BOOST_NOEXCEPT: + value_( 0u ) + { + } + + // Implicit (converting) constructor to allow passing source_location const* to error_code ctors and modifiers. + BOOST_SYSTEM_IMPLICIT source_location_ptr( source_location const* ptr ) BOOST_NOEXCEPT: + value_( reinterpret_cast( ptr ) ) + { + } + + BOOST_SYSTEM_CONSTEXPR boost::uintptr_t value() const BOOST_NOEXCEPT + { + return value_; + } + +private: + + boost::uintptr_t value_; + +}; + +} // namespace detail + +} // namespace system + +} // namespace boost + +#if defined(BOOST_DISABLE_CURRENT_LOCATION) + +# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr() + +#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926 + +// MSVC allows use of __builtin_FUNCTION() as a template argument; everything else is the same inside the lambda as +// outside. +# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ + []() \ + { \ + static BOOST_SYSTEM_CONSTEXPR ::boost::source_location loc_( \ + __builtin_FILE(), __builtin_LINE(), function_, __builtin_COLUMN() ); \ + return &loc_; \ + }.template operator()<__builtin_FUNCTION()>() ) + +#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && defined(BOOST_GCC) + +// gcc __builtin_source_location() returns std::source_location::__impl const* cast to void const*; we test that +// boost::source_location is layout-compatible with std::source_location::__impl, avoiding UB via memcpy. +# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ + static_cast<::boost::source_location const*>( __builtin_source_location() ) ) + +#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && defined(BOOST_CLANG) + +// Clang __builtin_source_location() returns std::source_location::__impl const*; same considerations as gcc. +# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ + reinterpret_cast<::boost::source_location const*>( __builtin_source_location() ) ) + +#elif (defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L) \ + || (defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000) \ + || (defined(BOOST_GCC) && BOOST_GCC >= 50000) + +// BOOST_CURRENT_LOCATION has function_name(), so we have to collect it outside the lambda. +# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ + []( ::boost::source_location loc ) \ + { \ + static const ::boost::source_location loc_ = loc; \ + return &loc_; \ + }( BOOST_CURRENT_LOCATION ) ) + +#else + +// no function_name(), so it's OK to collect BOOST_CURRENT_LOCATION inside the lambda. +# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ + []() \ + { \ + static BOOST_SYSTEM_CONSTEXPR ::boost::source_location loc_ = BOOST_CURRENT_LOCATION; \ + return &loc_; \ + }() ) + +#endif + +#endif // #ifndef BOOST_SYSTEM_DETAIL_SOURCE_LOCATION_HPP_INCLUDED diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d080497e..926d86fea 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,6 +61,12 @@ system_run(system_category_test.cpp) system_run(after_main_test.cpp) system_run(failed_test.cpp) system_run(failed_constexpr_test.cpp) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6 AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962 + set_source_files_properties(failed_constexpr_test.cpp PROPERTIES COMPILE_OPTIONS -fno-sanitize=undefined) +endif() boost_test(SOURCES warnings_test.cpp COMPILE_OPTIONS -Wall -Werror) @@ -123,6 +129,7 @@ boost_test(TYPE run SOURCES std_interop_test14.cpp) boost_test(TYPE run SOURCES ec_location_test3.cpp) boost_test(TYPE run SOURCES ec_location_test4.cpp) +boost_test(TYPE run SOURCES ec_location_test5.cpp) # result diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4a59edbd6..82d23742d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -151,6 +151,7 @@ run std_interop_test14.cpp ; run ec_location_test3.cpp ; run ec_location_test4.cpp ; +run ec_location_test5.cpp ; # result diff --git a/test/ec_location_test5.cpp b/test/ec_location_test5.cpp new file mode 100644 index 000000000..084977ea5 --- /dev/null +++ b/test/ec_location_test5.cpp @@ -0,0 +1,56 @@ +// Copyright 2021, 2022 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && defined(BOOST_GCC) + +struct get_std_source_location_impl_tag {}; +template< class T > +struct get_std_source_location_impl_t +{ + friend auto get_std_source_location_impl( get_std_source_location_impl_tag ) { return T(); } +}; +template struct get_std_source_location_impl_t; +auto get_std_source_location_impl( get_std_source_location_impl_tag ); +using std_source_location_impl = decltype( get_std_source_location_impl( get_std_source_location_impl_tag() ) ); + +static_assert( static_cast< const std_source_location_impl* >( __builtin_source_location() )->_M_line == __LINE__ ); + +static_assert( std::is_layout_compatible_v< boost::source_location, std_source_location_impl > ); + +#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && defined(BOOST_CLANG) + +static_assert( __builtin_source_location()->_M_line == __LINE__ ); + +static_assert( std::is_layout_compatible_v< boost::source_location, + std::remove_cvref_t< decltype( *__builtin_source_location() ) > > ); + +#endif + +int main() +{ + int const val = ENOENT; + boost::system::error_category const & cat = boost::system::generic_category(); + + { + BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION; + + boost::system::error_code ec( val, cat, BOOST_SYSTEM_CURRENT_LOCATION_PTR ); + + BOOST_TEST_EQ( ec.value(), val ); + BOOST_TEST_EQ( &ec.category(), &cat ); + + BOOST_TEST( ec.failed() ); + + BOOST_TEST( ec.has_location() ); + BOOST_TEST_EQ( ec.location().file_name(), loc.file_name() ); + BOOST_TEST_EQ( ec.location().function_name(), loc.function_name() ); + BOOST_TEST_EQ( ec.location().line(), loc.line() + 2 ); + } + + return boost::report_errors(); +} diff --git a/test/ec_what_test.cpp b/test/ec_what_test.cpp index 35c1e039a..798b40bf8 100644 --- a/test/ec_what_test.cpp +++ b/test/ec_what_test.cpp @@ -45,7 +45,7 @@ int main() BOOST_TEST_EQ( ec.value(), 5 ); BOOST_TEST( ec.category() == sys::generic_category() ); - BOOST_TEST_EQ( &ec.location(), &loc ); + BOOST_TEST_EQ( ec.location().line(), loc.line() ); BOOST_TEST_EQ( ec.what(), ec.message() + " [generic:5 at " + loc.to_string() + "]" ); } @@ -57,7 +57,7 @@ int main() BOOST_TEST_EQ( ec.value(), 5 ); BOOST_TEST( ec.category() == sys::system_category() ); - BOOST_TEST_EQ( &ec.location(), &loc ); + BOOST_TEST_EQ( ec.location().line(), loc.line() ); BOOST_TEST_EQ( ec.what(), ec.message() + " [system:5 at " + loc.to_string() + "]" ); } From 6c374fb1985bdeebac5b2bb38fcafa51190297d8 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Fri, 15 Jul 2022 23:27:23 +0100 Subject: [PATCH 2/9] fix compilation before C++11 --- include/boost/system/detail/source_location.hpp | 4 ++++ test/ec_location_test5.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/boost/system/detail/source_location.hpp b/include/boost/system/detail/source_location.hpp index 3b4f37edc..6ac07de0d 100644 --- a/include/boost/system/detail/source_location.hpp +++ b/include/boost/system/detail/source_location.hpp @@ -97,6 +97,10 @@ class source_location_ptr return &loc_; \ }( BOOST_CURRENT_LOCATION ) ) +#elif defined(BOOST_NO_CXX11_LAMBDAS) + +# define BOOST_SYSTEM_NO_CURRENT_LOCATION_PTR 1 + #else // no function_name(), so it's OK to collect BOOST_CURRENT_LOCATION inside the lambda. diff --git a/test/ec_location_test5.cpp b/test/ec_location_test5.cpp index 084977ea5..74461d64a 100644 --- a/test/ec_location_test5.cpp +++ b/test/ec_location_test5.cpp @@ -36,6 +36,7 @@ int main() int const val = ENOENT; boost::system::error_category const & cat = boost::system::generic_category(); +#if !defined(BOOST_SYSTEM_NO_CURRENT_LOCATION_PTR) { BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION; @@ -51,6 +52,7 @@ int main() BOOST_TEST_EQ( ec.location().function_name(), loc.function_name() ); BOOST_TEST_EQ( ec.location().line(), loc.line() + 2 ); } +#endif return boost::report_errors(); } From 464465cb4c33b11530e08acfe51ee44224c27223 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 17 Jul 2022 13:53:43 +0100 Subject: [PATCH 3/9] C++03 mode --- include/boost/system/detail/source_location.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/system/detail/source_location.hpp b/include/boost/system/detail/source_location.hpp index 6ac07de0d..db28b0bf7 100644 --- a/include/boost/system/detail/source_location.hpp +++ b/include/boost/system/detail/source_location.hpp @@ -86,8 +86,8 @@ class source_location_ptr reinterpret_cast<::boost::source_location const*>( __builtin_source_location() ) ) #elif (defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L) \ - || (defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000) \ - || (defined(BOOST_GCC) && BOOST_GCC >= 50000) + || (defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000 && !defined(BOOST_NO_CXX11_LAMBDAS)) \ + || (defined(BOOST_GCC) && BOOST_GCC >= 50000 && !defined(BOOST_NO_CXX11_LAMBDAS)) // BOOST_CURRENT_LOCATION has function_name(), so we have to collect it outside the lambda. # define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ @@ -99,6 +99,7 @@ class source_location_ptr #elif defined(BOOST_NO_CXX11_LAMBDAS) +// Not implementable without C++11 lambdas. # define BOOST_SYSTEM_NO_CURRENT_LOCATION_PTR 1 #else From 90a38aa420e91213a6c486e411ff3c4308e566a9 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 17 Jul 2022 14:06:35 +0100 Subject: [PATCH 4/9] fix unused variables, empty test tree --- test/ec_location_test5.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ec_location_test5.cpp b/test/ec_location_test5.cpp index 74461d64a..17333c148 100644 --- a/test/ec_location_test5.cpp +++ b/test/ec_location_test5.cpp @@ -33,10 +33,10 @@ static_assert( std::is_layout_compatible_v< boost::source_location, int main() { +#if !defined(BOOST_SYSTEM_NO_CURRENT_LOCATION_PTR) int const val = ENOENT; boost::system::error_category const & cat = boost::system::generic_category(); -#if !defined(BOOST_SYSTEM_NO_CURRENT_LOCATION_PTR) { BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION; @@ -52,7 +52,7 @@ int main() BOOST_TEST_EQ( ec.location().function_name(), loc.function_name() ); BOOST_TEST_EQ( ec.location().line(), loc.line() + 2 ); } -#endif return boost::report_errors(); +#endif } From f403e68e7fef3dda92a5aaba1f4084879a0283f3 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 17 Jul 2022 14:49:55 +0100 Subject: [PATCH 5/9] check for std::is_layout_compatible --- test/ec_location_test5.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/ec_location_test5.cpp b/test/ec_location_test5.cpp index 17333c148..d2614d9b4 100644 --- a/test/ec_location_test5.cpp +++ b/test/ec_location_test5.cpp @@ -20,14 +20,18 @@ using std_source_location_impl = decltype( get_std_source_location_impl( get_std static_assert( static_cast< const std_source_location_impl* >( __builtin_source_location() )->_M_line == __LINE__ ); +# if __cpp_lib_is_layout_compatible >= 201907L static_assert( std::is_layout_compatible_v< boost::source_location, std_source_location_impl > ); +# endif #elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && defined(BOOST_CLANG) static_assert( __builtin_source_location()->_M_line == __LINE__ ); +# if __cpp_lib_is_layout_compatible >= 201907L static_assert( std::is_layout_compatible_v< boost::source_location, std::remove_cvref_t< decltype( *__builtin_source_location() ) > > ); +# endif #endif From 98692c0afe334e608848e2e6ca915258440d0634 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 17 Jul 2022 15:28:10 +0100 Subject: [PATCH 6/9] remove clever MSVC code, it doesn't work the compiler gets confused whether __builtin_FUNCTION() (and the string it points to) is a compile-time constant, and fails or ICEs. Skip this for now. --- include/boost/system/detail/source_location.hpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/include/boost/system/detail/source_location.hpp b/include/boost/system/detail/source_location.hpp index db28b0bf7..c9800b0b4 100644 --- a/include/boost/system/detail/source_location.hpp +++ b/include/boost/system/detail/source_location.hpp @@ -60,18 +60,6 @@ class source_location_ptr # define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr() -#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926 - -// MSVC allows use of __builtin_FUNCTION() as a template argument; everything else is the same inside the lambda as -// outside. -# define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ - []() \ - { \ - static BOOST_SYSTEM_CONSTEXPR ::boost::source_location loc_( \ - __builtin_FILE(), __builtin_LINE(), function_, __builtin_COLUMN() ); \ - return &loc_; \ - }.template operator()<__builtin_FUNCTION()>() ) - #elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && defined(BOOST_GCC) // gcc __builtin_source_location() returns std::source_location::__impl const* cast to void const*; we test that From f5029a436e6c50877aec9eb5d89e7b94ef066319 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 17 Jul 2022 15:29:42 +0100 Subject: [PATCH 7/9] use strcmp to compare strings don't rely on string folding --- test/ec_location_test5.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/ec_location_test5.cpp b/test/ec_location_test5.cpp index d2614d9b4..96029b746 100644 --- a/test/ec_location_test5.cpp +++ b/test/ec_location_test5.cpp @@ -52,8 +52,8 @@ int main() BOOST_TEST( ec.failed() ); BOOST_TEST( ec.has_location() ); - BOOST_TEST_EQ( ec.location().file_name(), loc.file_name() ); - BOOST_TEST_EQ( ec.location().function_name(), loc.function_name() ); + BOOST_TEST_EQ( std::strcmp( ec.location().file_name(), loc.file_name() ), 0 ); + BOOST_TEST_EQ( std::strcmp( ec.location().function_name(), loc.function_name() ), 0 ); BOOST_TEST_EQ( ec.location().line(), loc.line() + 2 ); } From a8038d08e8ae26d9d178cbecbc8e0524c54179a4 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Sun, 17 Jul 2022 16:40:24 +0100 Subject: [PATCH 8/9] fix MSVC --- include/boost/system/detail/source_location.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/system/detail/source_location.hpp b/include/boost/system/detail/source_location.hpp index c9800b0b4..5030d6082 100644 --- a/include/boost/system/detail/source_location.hpp +++ b/include/boost/system/detail/source_location.hpp @@ -74,6 +74,7 @@ class source_location_ptr reinterpret_cast<::boost::source_location const*>( __builtin_source_location() ) ) #elif (defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L) \ + || (defined(BOOST_MSVC) && BOOST_MSVC >= 1926) \ || (defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000 && !defined(BOOST_NO_CXX11_LAMBDAS)) \ || (defined(BOOST_GCC) && BOOST_GCC >= 50000 && !defined(BOOST_NO_CXX11_LAMBDAS)) From 1f839cc2ba3c67601dcf4050050914db7d2d2b36 Mon Sep 17 00:00:00 2001 From: Ed Catmur Date: Tue, 19 Jul 2022 18:53:02 +0100 Subject: [PATCH 9/9] add lambda return types for Visual Studio 2015 MSVC 9.0 --- include/boost/system/detail/source_location.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/system/detail/source_location.hpp b/include/boost/system/detail/source_location.hpp index 5030d6082..9b54a6f75 100644 --- a/include/boost/system/detail/source_location.hpp +++ b/include/boost/system/detail/source_location.hpp @@ -80,7 +80,7 @@ class source_location_ptr // BOOST_CURRENT_LOCATION has function_name(), so we have to collect it outside the lambda. # define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ - []( ::boost::source_location loc ) \ + []( ::boost::source_location loc ) -> ::boost::source_location const* \ { \ static const ::boost::source_location loc_ = loc; \ return &loc_; \ @@ -95,7 +95,7 @@ class source_location_ptr // no function_name(), so it's OK to collect BOOST_CURRENT_LOCATION inside the lambda. # define BOOST_SYSTEM_CURRENT_LOCATION_PTR ::boost::system::detail::source_location_ptr( \ - []() \ + []() -> ::boost::source_location const* \ { \ static BOOST_SYSTEM_CONSTEXPR ::boost::source_location loc_ = BOOST_CURRENT_LOCATION; \ return &loc_; \