From 72761e34e0e49be6049c989e7ad9ccd16b987b44 Mon Sep 17 00:00:00 2001 From: Mohammad Nejati Date: Sat, 13 Jul 2024 08:35:54 +0000 Subject: [PATCH 1/6] Rename typedef `base` to `core_ev_base` Using typedef `base` poses a high risk of name conflict, given that `empty_value` is inherited in user types. --- include/boost/core/empty_value.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/core/empty_value.hpp b/include/boost/core/empty_value.hpp index bb95841..9f04d61 100644 --- a/include/boost/core/empty_value.hpp +++ b/include/boost/core/empty_value.hpp @@ -138,10 +138,10 @@ template class empty_value #if defined(BOOST_MSVC) : detail::empty_value_base { - typedef detail::empty_value_base base; + typedef detail::empty_value_base core_ev_base; #else : T { - typedef T base; + typedef T core_ev_base; #endif public: @@ -154,26 +154,26 @@ public: #endif BOOST_CONSTEXPR empty_value(boost::empty_init_t) - : base() { } + : core_ev_base() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value, Args&&... args) - : base(std::forward(value), std::forward(args)...) { } + : core_ev_base(std::forward(value), std::forward(args)...) { } #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value) - : base(std::forward(value)) { } + : core_ev_base(std::forward(value)) { } #endif #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, const U& value) - : base(value) { } + : core_ev_base(value) { } template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U& value) - : base(value) { } + : core_ev_base(value) { } #endif BOOST_CONSTEXPR const T& get() const BOOST_NOEXCEPT { From d66b8c1c13ac23c12b81496b96179d44223a0053 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 13 Jul 2024 13:29:07 +0300 Subject: [PATCH 2/6] Update ci.yml --- .github/workflows/ci.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4bdfc6..9408e6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,6 +128,13 @@ jobs: container: ubuntu:23.04 install: - g++-13-multilib + - toolset: gcc-14 + cxxstd: "03,11,14,17,20,23" + address-model: 32,64 + os: ubuntu-latest + container: ubuntu:24.04 + install: + - g++-14-multilib - name: UBSAN toolset: gcc-12 cxxstd: "03,11,14,17,20,23" @@ -286,15 +293,23 @@ jobs: - toolset: clang compiler: clang++-17 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + os: ubuntu-latest + container: ubuntu:23.10 install: - clang-17 - libc++-17-dev - libc++abi-17-dev - sources: - - "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" - source_keys: - - "https://apt.llvm.org/llvm-snapshot.gpg.key" + cxxflags: -stdlib=libc++ + linkflags: -stdlib=libc++ + - toolset: clang + compiler: clang++-18 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-latest + container: ubuntu:24.04 + install: + - clang-18 + - libc++-18-dev + - libc++abi-18-dev cxxflags: -stdlib=libc++ linkflags: -stdlib=libc++ - name: UBSAN From bda05a781231931a97e5046baf824426f00f922e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 13 Jul 2024 15:41:26 +0300 Subject: [PATCH 3/6] Update .drone.jsonnet --- .drone.jsonnet | 54 +++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index c6881fb..4927b18 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -200,31 +200,38 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 23.04 GCC 13 32 ASAN", + "Linux 23.04 GCC 13 32/64", "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan, + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' }, "g++-13-multilib", ), linux_pipeline( - "Linux 23.04 GCC 13 64 ASAN", - "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan, - "g++-13-multilib", + "Linux 24.04 GCC 14 32 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan, + "g++-14-multilib", ), linux_pipeline( - "Linux 23.04 GCC 13 32 UBSAN", - "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + ubsan, - "g++-13-multilib", + "Linux 24.04 GCC 14 64 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan, + "g++-14-multilib", ), linux_pipeline( - "Linux 23.04 GCC 13 64 UBSAN", - "cppalliance/droneubuntu2304:1", - { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + ubsan, - "g++-13-multilib", + "Linux 24.04 GCC 14 32 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + ubsan, + "g++-14-multilib", + ), + + linux_pipeline( + "Linux 24.04 GCC 14 64 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + ubsan, + "g++-14-multilib", ), linux_pipeline( @@ -354,17 +361,24 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 23.10 Clang 17 UBSAN", + "Linux 23.10 Clang 17", "cppalliance/droneubuntu2310:1", - { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' }, "clang-17", ), linux_pipeline( - "Linux 23.10 Clang 17 ASAN", - "cppalliance/droneubuntu2310:1", - { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan, - "clang-17", + "Linux 24.04 Clang 18 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + "clang-18", + ), + + linux_pipeline( + "Linux 24.04 Clang 18 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan, + "clang-18", ), macos_pipeline( From 76061d91d4b695d3a3644196c860e5feb0e6f0bf Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sun, 14 Jul 2024 07:04:23 -0400 Subject: [PATCH 4/6] Move compile test to separate source file --- test/Jamfile.v2 | 1 + test/empty_value_nested_test.cpp | 45 ++++++++++++++++++++++++++++++++ test/empty_value_test.cpp | 34 ------------------------ 3 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 test/empty_value_nested_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e9a1d07..8c27813 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -226,6 +226,7 @@ run empty_value_test.cpp ; run empty_value_size_test.cpp ; run empty_value_final_test.cpp ; run empty_value_constexpr_test.cpp ; +compile empty_value_nested_test.cpp ; compile-fail empty_value_compile_fail_casting.cpp ; run quick_exit_test.cpp ; diff --git a/test/empty_value_nested_test.cpp b/test/empty_value_nested_test.cpp new file mode 100644 index 0000000..7c011a5 --- /dev/null +++ b/test/empty_value_nested_test.cpp @@ -0,0 +1,45 @@ +/* +Copyright 2024 Braden Ganetsky +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include + +/* +Tests workaround for MSVC bug: +https://developercommunity.visualstudio.com/t/Compiler-bug:-Incorrect-C2247-and-C2248/10690025 +*/ +template +struct derived + : boost::empty_value { + typedef typename boost::empty_value::type type; + derived(boost::empty_init_t e) + : boost::empty_value(e) { } +}; + +struct outer { + struct inner_empty { }; + struct inner_non_empty { + inner_non_empty() + : value() { } + int value; + }; +}; + +void test() +{ + const boost::empty_value x1(boost::empty_init); + (void)x1; + const boost::empty_value x2(boost::empty_init); + (void)x2; + const boost::empty_value x3(boost::empty_init); + (void)x3; + const derived x4(boost::empty_init); + (void)x4; + const derived x5(boost::empty_init); + (void)x5; + const derived x6(boost::empty_init); + (void)x6; +} diff --git a/test/empty_value_test.cpp b/test/empty_value_test.cpp index 44dba4c..b7cf796 100644 --- a/test/empty_value_test.cpp +++ b/test/empty_value_test.cpp @@ -63,40 +63,6 @@ void test_type() BOOST_TEST(v2.get().value() == 6); } -template -struct derived : boost::empty_value { - typedef typename boost::empty_value::type type; - derived(boost::empty_init_t e) : boost::empty_value(e) {} -}; - -struct outer { - struct inner_empty {}; - struct inner_non_empty { - inner_non_empty() : value() {} - int value; - }; -}; - -void test_derived_compile() -{ - // This is testing the workaround to an MSVC bug when T is a nested class. - // See https://developercommunity.visualstudio.com/t/Compiler-bug:-Incorrect-C2247-and-C2248/10690025 - - const boost::empty_value x1(boost::empty_init); - const boost::empty_value x2(boost::empty_init); - const boost::empty_value x3(boost::empty_init); - const derived x4(boost::empty_init); - const derived x5(boost::empty_init); - const derived x6(boost::empty_init); - - (void)x1; - (void)x2; - (void)x3; - (void)x4; - (void)x5; - (void)x6; -} - int main() { test_int(); From 242b14bb690ca7b4f924b6dd35f397a2779813a3 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sun, 14 Jul 2024 07:14:38 -0400 Subject: [PATCH 5/6] Rename base typedef --- include/boost/core/empty_value.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/core/empty_value.hpp b/include/boost/core/empty_value.hpp index 9f04d61..6728bc2 100644 --- a/include/boost/core/empty_value.hpp +++ b/include/boost/core/empty_value.hpp @@ -138,10 +138,10 @@ template class empty_value #if defined(BOOST_MSVC) : detail::empty_value_base { - typedef detail::empty_value_base core_ev_base; + typedef detail::empty_value_base base_type; #else : T { - typedef T core_ev_base; + typedef T base_type; #endif public: @@ -154,26 +154,26 @@ public: #endif BOOST_CONSTEXPR empty_value(boost::empty_init_t) - : core_ev_base() { } + : base_type() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value, Args&&... args) - : core_ev_base(std::forward(value), std::forward(args)...) { } + : base_type(std::forward(value), std::forward(args)...) { } #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value) - : core_ev_base(std::forward(value)) { } + : base_type(std::forward(value)) { } #endif #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, const U& value) - : core_ev_base(value) { } + : base_type(value) { } template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U& value) - : core_ev_base(value) { } + : base_type(value) { } #endif BOOST_CONSTEXPR const T& get() const BOOST_NOEXCEPT { From 9e9e6e3898085b2ec93f82b9ce099b556c5ccfc0 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Tue, 16 Jul 2024 23:53:47 -0400 Subject: [PATCH 6/6] Rename base type again --- include/boost/core/empty_value.hpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/include/boost/core/empty_value.hpp b/include/boost/core/empty_value.hpp index 6728bc2..5eeee51 100644 --- a/include/boost/core/empty_value.hpp +++ b/include/boost/core/empty_value.hpp @@ -96,8 +96,10 @@ private: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #if defined(BOOST_MSVC) -// This is a workaround to an MSVC bug when T is a nested class. -// See https://developercommunity.visualstudio.com/t/Compiler-bug:-Incorrect-C2247-and-C2248/10690025 +/* +This is a workaround to an MSVC bug when T is a nested class: +https://developercommunity.visualstudio.com/t/Compiler-bug:-Incorrect-C2247-and-C2248/10690025 +*/ namespace detail { template @@ -138,10 +140,10 @@ template class empty_value #if defined(BOOST_MSVC) : detail::empty_value_base { - typedef detail::empty_value_base base_type; + typedef detail::empty_value_base empty_base_; #else : T { - typedef T base_type; + typedef T empty_base_; #endif public: @@ -154,26 +156,26 @@ public: #endif BOOST_CONSTEXPR empty_value(boost::empty_init_t) - : base_type() { } + : empty_base_() { } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value, Args&&... args) - : base_type(std::forward(value), std::forward(args)...) { } + : empty_base_(std::forward(value), std::forward(args)...) { } #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U&& value) - : base_type(std::forward(value)) { } + : empty_base_(std::forward(value)) { } #endif #else template BOOST_CONSTEXPR empty_value(boost::empty_init_t, const U& value) - : base_type(value) { } + : empty_base_(value) { } template BOOST_CONSTEXPR empty_value(boost::empty_init_t, U& value) - : base_type(value) { } + : empty_base_(value) { } #endif BOOST_CONSTEXPR const T& get() const BOOST_NOEXCEPT {