From 1abda5b829e0e7285f8b7f66d5f9b604f39902be Mon Sep 17 00:00:00 2001 From: zhangzhangxin Date: Fri, 12 May 2023 10:03:26 +0800 Subject: [PATCH] sync:Fix c++20 compilation problem for clang10 and fix potential bug due to compiler optimization Signed-off-by: zhangzhangxin --- ...c-20-compilation-problem-for-clang10.patch | 33 +++++++++++++++++++ jsoncpp.spec | 6 +++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 0005-sync-Fix-c-20-compilation-problem-for-clang10.patch diff --git a/0005-sync-Fix-c-20-compilation-problem-for-clang10.patch b/0005-sync-Fix-c-20-compilation-problem-for-clang10.patch new file mode 100644 index 0000000..08ed940 --- /dev/null +++ b/0005-sync-Fix-c-20-compilation-problem-for-clang10.patch @@ -0,0 +1,33 @@ +From 98361556e6ad47f4edb1f3615341ba4b6f3ff552 Mon Sep 17 00:00:00 2001 +From: zhangzhangxin +Date: Fri, 12 May 2023 09:52:03 +0800 +Subject: [PATCH] sync:Fix c++20 compilation problem for clang10 and fix + potential bug due to compiler optimization + +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..95ef8a5 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 bc5a62e..c4929ff 100644 --- a/jsoncpp.spec +++ b/jsoncpp.spec @@ -1,6 +1,6 @@ Name: jsoncpp Version: 1.9.3 -Release: 6 +Release: 7 Summary: JSON C++ library License: Public Domain or MIT URL: https://github.com/open-source-parsers/jsoncpp @@ -10,6 +10,7 @@ Patch0: 0001-sync-Issue-1182-Fix-fuzzing-bug.patch Patch1: 0002-sync-avoid-isprint-because-it-is-locale-specific.patch Patch2: 0003-sync-Add-nullptr-Json-Value-constructor.patch Patch3: 0004-sync-Fix-generation-of-pkg-config-file-with-absolute.patch +Patch4: 0005-sync-Fix-c-20-compilation-problem-for-clang10.patch %description JsonCpp is a C++ library that allows manipulating JSON values, @@ -91,6 +92,9 @@ hardlink -cfv %{buildroot}%{_docdir}/%{name} %changelog +* Fri May 12 2023 zhangxin - 1.9.3-7 +- Fix c++20 compilation problem for clang10 and fix potential bug due to compiler optimization + * Fri Apr 28 2023 zhangxin - 1.9.3-6 - Fix generation of pkg-config file with absolute includedir/libdir. -- Gitee