From 9075be8758c69aa545d8a29c3a65c8edeba667c6 Mon Sep 17 00:00:00 2001 From: zhangzhangxin Date: Tue, 25 Apr 2023 15:14:26 +0800 Subject: [PATCH 1/2] sync:Fix c++20 compilation problem for clang10 Signed-off-by: zhangzhangxin --- ...c-20-compilation-problem-for-clang10.patch | 32 +++++++++++++++++++ jsoncpp.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 0001-sync-Fix-c-20-compilation-problem-for-clang10.patch diff --git a/0001-sync-Fix-c-20-compilation-problem-for-clang10.patch b/0001-sync-Fix-c-20-compilation-problem-for-clang10.patch new file mode 100644 index 0000000..121eb6d --- /dev/null +++ b/0001-sync-Fix-c-20-compilation-problem-for-clang10.patch @@ -0,0 +1,32 @@ +From 5281ac8fa2cee62e7baa2dec70885de3363bc4ec Mon Sep 17 00:00:00 2001 +From: zhangzhangxin +Date: Tue, 25 Apr 2023 14:49:51 +0800 +Subject: [PATCH] sync:Fix c++20 compilation problem for clang10 + +Signed-off-by: zhangzhangxin +--- + include/json/allocator.h | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/include/json/allocator.h b/include/json/allocator.h +index 0f5c224..91af302 100644 +--- a/include/json/allocator.h ++++ b/include/json/allocator.h +@@ -35,11 +35,10 @@ public: + * Release memory which was allocated for N items at pointer P. + * + * The memory block is filled with zeroes before being released. +- * The pointer argument is tagged as "volatile" to prevent the +- * compiler optimizing out this critical step. + */ +- void deallocate(volatile pointer p, size_type n) { +- std::memset(p, 0, n * sizeof(T)); ++ void deallocate(pointer p, size_type n) { ++ // memset_s is used because memset may be optimized away by the compiler ++ memset_s(p, n * sizeof(T), 0, n * sizeof(T)); + // free using "global operator delete" + ::operator delete(p); + } +-- +2.40.0.windows.1 + diff --git a/jsoncpp.spec b/jsoncpp.spec index b8af957..85c76ef 100644 --- a/jsoncpp.spec +++ b/jsoncpp.spec @@ -1,11 +1,12 @@ Name: jsoncpp Version: 1.9.4 -Release: 1 +Release: 2 Summary: JSON C++ library License: Public Domain or MIT URL: https://github.com/open-source-parsers/jsoncpp Source0: https://github.com/open-source-parsers/jsoncpp/archive/%{version}/%{name}-%{version}.tar.gz BuildRequires: gcc-c++ cmake >= 3.1 python3-devel +Patch0: 0001-sync-Fix-c-20-compilation-problem-for-clang10.patch %description JsonCpp is a C++ library that allows manipulating JSON values, @@ -88,6 +89,9 @@ hardlink -cfv %{buildroot}%{_docdir}/%{name} %changelog +* Tue Apr 25 2023 zhangxin - 1.9.4-2 +- sync:Fix c++20 compilation problem for clang10 + * Wed Feb 3 2021 liudabo - 1.9.4-1 - upgrade version to 1.9.4 -- Gitee From f44f94ebe1b199645c650a1c04e531e6a0303113 Mon Sep 17 00:00:00 2001 From: zhangzhangxin Date: Tue, 25 Apr 2023 20:35:48 +0800 Subject: [PATCH 2/2] sync:Fix c++20 compilation problem for clang10 #1228 Signed-off-by: zhangzhangxin --- ...-compilation-problem-for-clang10-1228.patch | 18 +++++++++--------- jsoncpp.spec | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) rename 0001-sync-Fix-c-20-compilation-problem-for-clang10.patch => 0001-sync-Fix-c-20-compilation-problem-for-clang10-1228.patch (61%) diff --git a/0001-sync-Fix-c-20-compilation-problem-for-clang10.patch b/0001-sync-Fix-c-20-compilation-problem-for-clang10-1228.patch similarity index 61% rename from 0001-sync-Fix-c-20-compilation-problem-for-clang10.patch rename to 0001-sync-Fix-c-20-compilation-problem-for-clang10-1228.patch index 121eb6d..a5107b5 100644 --- a/0001-sync-Fix-c-20-compilation-problem-for-clang10.patch +++ b/0001-sync-Fix-c-20-compilation-problem-for-clang10-1228.patch @@ -1,17 +1,17 @@ -From 5281ac8fa2cee62e7baa2dec70885de3363bc4ec Mon Sep 17 00:00:00 2001 +From a73d35d61b5a0f41c30b85a4b00a7f10786e5a5d Mon Sep 17 00:00:00 2001 From: zhangzhangxin -Date: Tue, 25 Apr 2023 14:49:51 +0800 -Subject: [PATCH] sync:Fix c++20 compilation problem for clang10 +Date: Tue, 25 Apr 2023 20:29:33 +0800 +Subject: [PATCH] sync:Fix c++20 compilation problem for clang10 #1228 Signed-off-by: zhangzhangxin --- - include/json/allocator.h | 7 +++---- + jsoncpp-1.9.4/include/json/allocator.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -diff --git a/include/json/allocator.h b/include/json/allocator.h -index 0f5c224..91af302 100644 ---- a/include/json/allocator.h -+++ b/include/json/allocator.h +diff --git a/jsoncpp-1.9.4/include/json/allocator.h b/jsoncpp-1.9.4/include/json/allocator.h +index 0f5c224..95ef8a5 100644 +--- a/jsoncpp-1.9.4/include/json/allocator.h ++++ b/jsoncpp-1.9.4/include/json/allocator.h @@ -35,11 +35,10 @@ public: * Release memory which was allocated for N items at pointer P. * @@ -21,7 +21,7 @@ index 0f5c224..91af302 100644 */ - void deallocate(volatile pointer p, size_type n) { - std::memset(p, 0, n * sizeof(T)); -+ void deallocate(pointer p, size_type n) { ++ void deallocate(pointer p, size_type n) { + // memset_s is used because memset may be optimized away by the compiler + memset_s(p, n * sizeof(T), 0, n * sizeof(T)); // free using "global operator delete" diff --git a/jsoncpp.spec b/jsoncpp.spec index 85c76ef..79fe060 100644 --- a/jsoncpp.spec +++ b/jsoncpp.spec @@ -6,7 +6,7 @@ License: Public Domain or MIT URL: https://github.com/open-source-parsers/jsoncpp Source0: https://github.com/open-source-parsers/jsoncpp/archive/%{version}/%{name}-%{version}.tar.gz BuildRequires: gcc-c++ cmake >= 3.1 python3-devel -Patch0: 0001-sync-Fix-c-20-compilation-problem-for-clang10.patch +Patch0: 0001-sync-Fix-c-20-compilation-problem-for-clang10-1228.patch %description JsonCpp is a C++ library that allows manipulating JSON values, -- Gitee