From 08e9dc0a8c697fb9c225bfb214131d9e5b2c045f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 10 Nov 2018 11:03:15 +0100 Subject: [PATCH 1/8] Fix compilation warnings. --- example/doc_complex_map.cpp | 5 +++++ example/doc_managed_allocation_command.cpp | 6 ++++++ test/shared_ptr_test.cpp | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/example/doc_complex_map.cpp b/example/doc_complex_map.cpp index 2d40086..63c90b6 100644 --- a/example/doc_complex_map.cpp +++ b/example/doc_complex_map.cpp @@ -44,6 +44,11 @@ class complex_data : id_(id), char_string_(name, void_alloc), int_vector_vector_(void_alloc) {} //Other members... + //<- + int get_id() { return id_; }; + char_string get_char_string() { return char_string_; }; + int_vector_vector get_int_vector_vector() { return int_vector_vector_; }; + //-> }; //Definition of the map holding a string as key and complex_data as mapped type diff --git a/example/doc_managed_allocation_command.cpp b/example/doc_managed_allocation_command.cpp index c5e7fa1..e1e0cf4 100644 --- a/example/doc_managed_allocation_command.cpp +++ b/example/doc_managed_allocation_command.cpp @@ -88,6 +88,9 @@ int main() //Get free memory and compare managed_shared_memory::size_type free_memory_after_expansion = managed_shm.get_free_memory(); assert(free_memory_after_expansion < free_memory_after_allocation); + //<- + (void)free_memory_after_expansion; + //-> //Write new values for(std::size_t i = first_received_size; i < expanded_size; ++i) ptr[i] = i; @@ -109,6 +112,9 @@ int main() //Get free memory and compare managed_shared_memory::size_type free_memory_after_shrinking = managed_shm.get_free_memory(); assert(free_memory_after_shrinking > free_memory_after_expansion); + //<- + (void)free_memory_after_shrinking; + //-> //Deallocate the buffer managed_shm.deallocate(ptr); diff --git a/test/shared_ptr_test.cpp b/test/shared_ptr_test.cpp index b523acc..1785845 100644 --- a/test/shared_ptr_test.cpp +++ b/test/shared_ptr_test.cpp @@ -274,7 +274,7 @@ struct X { X(){ ++cnt; } // virtual destructor deliberately omitted - ~X(){ --cnt; } + virtual ~X(){ --cnt; } virtual int id() const { return 1; } @@ -287,7 +287,7 @@ struct X struct Y: public X { Y(){ ++cnt; } - ~Y(){ --cnt; } + virtual ~Y(){ --cnt; } virtual int id() const { return 2; } From 28a6faa210cbfd2f14d23c4ed36b06831c12901e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 10 Nov 2018 11:03:33 +0100 Subject: [PATCH 2/8] Add compiler deprecation warning. --- doc/interprocess.qbk | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index 17a0aaf..dfa1c21 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -73,9 +73,10 @@ your system's documentation to know which library implements them. [*Boost.Interprocess] has been tested in the following compilers/platforms: -* Visual >= 7.1 -* GCC >= 4.1 -* Intel 11 +* Visual C++ >= 7.1. +* GCC >= 4.1. + +[warning GCC < 4.3 and MSVC < 9.0 are deprecated and will be removed in the next version.] [endsect] @@ -6763,6 +6764,9 @@ thank them: [section:release_notes Release Notes] [section:release_notes_boost_1_69_00 Boost 1.69 Release] + +* Deprecated GCC < 4.3 and MSVC < 9.0 (Visual 2008) compilers. + * Fixed bugs: * [@https://github.com/boostorg/interprocess/issues/59 GitHub Issue #59 (['"warning: ISO C++ prohibits anonymous structs [-Wpedantic]"])]. * [@https://github.com/boostorg/interprocess/issues/60 GitHub Issue #60 (['"warning: cast between incompatible function types from boost::interprocess::winapi::farproc_t..."])]. From 1b3dcf981437d2f389be13a385c183fedc187076 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Sun, 11 Nov 2018 22:31:15 +0000 Subject: [PATCH 3/8] Prepare for C++20 and remove "throw()" usage. --- include/boost/interprocess/exceptions.hpp | 8 ++++---- .../boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/interprocess/exceptions.hpp b/include/boost/interprocess/exceptions.hpp index 700c4c5..336a5fc 100644 --- a/include/boost/interprocess/exceptions.hpp +++ b/include/boost/interprocess/exceptions.hpp @@ -60,9 +60,9 @@ class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception catch(...){} } - virtual ~interprocess_exception() throw(){} + virtual ~interprocess_exception() BOOST_NOEXCEPT_OR_NOTHROW {} - virtual const char * what() const throw() + virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW { return m_str.c_str(); } native_error_t get_native_error()const { return m_err.get_native_error(); } @@ -86,7 +86,7 @@ class BOOST_SYMBOL_VISIBLE lock_exception : public interprocess_exception : interprocess_exception(lock_error) {} - virtual const char* what() const throw() + virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW { return "boost::interprocess::lock_exception"; } }; @@ -97,7 +97,7 @@ class BOOST_SYMBOL_VISIBLE bad_alloc : public interprocess_exception { public: bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){} - virtual const char* what() const throw() + virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW { return "boost::interprocess::bad_alloc"; } }; diff --git a/include/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp b/include/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp index 416f7a4..3e2b4df 100644 --- a/include/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/detail/bad_weak_ptr.hpp @@ -36,7 +36,7 @@ class bad_weak_ptr { public: - virtual char const * what() const throw() + virtual char const * what() const BOOST_NOEXCEPT_OR_NOTHROW { return "boost::interprocess::bad_weak_ptr"; } }; From aecde39cc873cfba9fd738c193f1f8f6e07e7f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 16 Nov 2018 23:28:00 +0100 Subject: [PATCH 4/8] Update changelog with pull #68 --- doc/interprocess.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index dfa1c21..fee02ac 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6771,6 +6771,7 @@ thank them: * [@https://github.com/boostorg/interprocess/issues/59 GitHub Issue #59 (['"warning: ISO C++ prohibits anonymous structs [-Wpedantic]"])]. * [@https://github.com/boostorg/interprocess/issues/60 GitHub Issue #60 (['"warning: cast between incompatible function types from boost::interprocess::winapi::farproc_t..."])]. * [@https://github.com/boostorg/interprocess/issues/61 GitHub Issue #61 (['"warning: struct winapi::*_BIPC has virtual functions and accessible non-virtual destructor"])]. + * [@https://github.com/boostorg/interprocess/pull/68 GitHub Pull #68 (['"Prepare for C++20 and remove "throw()" usage"])]. [endsect] From 53f328f4c173148c9c4c2a98bd596e504d392f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 17 Nov 2018 00:21:41 +0100 Subject: [PATCH 5/8] Fix warnings about throwing destructors, which are by default noexcept --- test/intermodule_singleton_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/intermodule_singleton_test.cpp b/test/intermodule_singleton_test.cpp index ce1e59c..915a9fe 100644 --- a/test/intermodule_singleton_test.cpp +++ b/test/intermodule_singleton_test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include //for std::abort using namespace boost::interprocess; @@ -184,7 +185,8 @@ class LogPhoenixTester sstr << "Logger::constructed_times != Logger::destroyed_times\n"; sstr << "(" << Logger::constructed_times << " vs. " << Logger::destroyed_times << ")\n"; } - throw std::runtime_error(sstr.str().c_str()); + std::cout << "~LogPhoenixTester(), error: " << sstr.str() << std::endl; + std::abort(); } } }; @@ -214,7 +216,8 @@ class LogDeadReferenceUser LogSingleton::get().log_it(); std::string s("LogDeadReferenceUser failed for LogSingleton "); s += typeid(LogSingleton).name(); - throw std::runtime_error(s.c_str()); + std::cout << "~LogDeadReferenceUser(), error: " << s << std::endl; + std::abort(); } catch(interprocess_exception &){ //Correct behaviour From fbf326ccf16081ce627f7107023a2e1cc9975534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 17 Nov 2018 00:21:56 +0100 Subject: [PATCH 6/8] Remove unused variable FileSize --- test/file_lock_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/file_lock_test.cpp b/test/file_lock_test.cpp index 22738de..6dcfd92 100644 --- a/test/file_lock_test.cpp +++ b/test/file_lock_test.cpp @@ -21,7 +21,6 @@ using namespace boost::interprocess; -static const std::size_t FileSize = 1000; inline std::string get_filename() { std::string ret (ipcdetail::get_temporary_path()); From 1e89871cdd0f2c5534e4b573f51ad792bfad6b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 17 Nov 2018 00:22:25 +0100 Subject: [PATCH 7/8] Enable test again, check BOOST_INTERPROCESS_MAPPED_FILES after workaround.hpp is included --- test/managed_mapped_file_test.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/managed_mapped_file_test.cpp b/test/managed_mapped_file_test.cpp index 1b83759..8185e56 100644 --- a/test/managed_mapped_file_test.cpp +++ b/test/managed_mapped_file_test.cpp @@ -8,9 +8,11 @@ // ////////////////////////////////////////////////////////////////////////////// +#include +#include + #if defined(BOOST_INTERPROCESS_MAPPED_FILES) -#include #include #include #include @@ -225,8 +227,6 @@ int main () return 0; } -#include - #else //#if defined(BOOST_INTERPROCESS_MAPPED_FILES) int main() @@ -235,3 +235,5 @@ int main() } #endif//#if defined(BOOST_INTERPROCESS_MAPPED_FILES) + +#include From 4e2c06b24211e4983dad95d4b1035d1e0602490d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 17 Nov 2018 00:23:15 +0100 Subject: [PATCH 8/8] Fix Issue #64 ("UBSan: runtime error: load of value 4294967295 [...] for type 'boost::interprocess::mode_t') --- doc/interprocess.qbk | 1 + include/boost/interprocess/detail/file_wrapper.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index fee02ac..27124a2 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6771,6 +6771,7 @@ thank them: * [@https://github.com/boostorg/interprocess/issues/59 GitHub Issue #59 (['"warning: ISO C++ prohibits anonymous structs [-Wpedantic]"])]. * [@https://github.com/boostorg/interprocess/issues/60 GitHub Issue #60 (['"warning: cast between incompatible function types from boost::interprocess::winapi::farproc_t..."])]. * [@https://github.com/boostorg/interprocess/issues/61 GitHub Issue #61 (['"warning: struct winapi::*_BIPC has virtual functions and accessible non-virtual destructor"])]. + * [@https://github.com/boostorg/interprocess/issues/64 GitHub Issue #64 (['"UBSan: runtime error: load of value 4294967295, (...) for type 'boost::interprocess::mode_t'"])]. * [@https://github.com/boostorg/interprocess/pull/68 GitHub Pull #68 (['"Prepare for C++20 and remove "throw()" usage"])]. [endsect] diff --git a/include/boost/interprocess/detail/file_wrapper.hpp b/include/boost/interprocess/detail/file_wrapper.hpp index 58f28e9..99e0fea 100644 --- a/include/boost/interprocess/detail/file_wrapper.hpp +++ b/include/boost/interprocess/detail/file_wrapper.hpp @@ -113,12 +113,13 @@ class file_wrapper bool priv_open_or_create(ipcdetail::create_enum_t type, const char *filename, mode_t mode, const permissions &perm); file_handle_t m_handle; - mode_t m_mode; - std::string m_filename; + mode_t m_mode; + std::string m_filename; }; inline file_wrapper::file_wrapper() - : m_handle(file_handle_t(ipcdetail::invalid_file())) + : m_handle(file_handle_t(ipcdetail::invalid_file())) + , m_mode(read_only), m_filename() {} inline file_wrapper::~file_wrapper()