fix build error due to gcc upgrade to 12

This commit is contained in:
chen-jan 2023-07-20 15:31:24 +08:00
parent eabdc871ea
commit ea4f29317d
2 changed files with 67 additions and 1 deletions

View File

@ -5,7 +5,7 @@
%endif %endif
Name: flatbuffers Name: flatbuffers
Version: 2.0.0 Version: 2.0.0
Release: 5 Release: 6
Summary: Memory efficient serialization library Summary: Memory efficient serialization library
License: Apache-2.0 License: Apache-2.0
URL: https://github.com/google/flatbuffers URL: https://github.com/google/flatbuffers
@ -18,6 +18,7 @@ Patch1: 0002-typo-fixes-in-comments.patch
Patch2: 0003-Changes-to-support-binary-schema-file-loading-and-pa.patch Patch2: 0003-Changes-to-support-binary-schema-file-loading-and-pa.patch
Patch3: 0004-output-errors-instead-of-stdout.patch Patch3: 0004-output-errors-instead-of-stdout.patch
Patch4: 0005-fix-undefined-behaviour.patch Patch4: 0005-fix-undefined-behaviour.patch
Patch5: test-fix-undefined-order-of-functio-parameters.-6946.patch
BuildRequires: gcc-c++ cmake >= 2.8.9 BuildRequires: gcc-c++ cmake >= 2.8.9
Provides: bundled(grpc) Provides: bundled(grpc)
@ -94,6 +95,9 @@ make test
%{python3_sitelib}/ %{python3_sitelib}/
%changelog %changelog
* Thu Jul 20 2023 chenchen <chen_aka_jan@163.com> - 2.0.0-6
- fix build error due to gcc upgrade to 12
* Tue Nov 22 2022 Bin Hu <hubin73@huawei.com> - 2.0.0-5 * Tue Nov 22 2022 Bin Hu <hubin73@huawei.com> - 2.0.0-5
- add python subpackage for tensorflow 2.10 build - add python subpackage for tensorflow 2.10 build

View File

@ -0,0 +1,62 @@
From 85b4effac69202fb360db16ffd0354ef76baa321 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Mon, 22 Nov 2021 20:14:31 +0000
Subject: [PATCH] test: fix undefined order of functio parameters. (#6946)
Detected instability when built `flatbuffers-2.0.0` on `gcc-12`:
[ 75%] Building CXX object CMakeFiles/flattests.dir/tests/test_builder.cpp.o
.../c++/12.0.0/bits/shared_ptr_base.h:397:45: error: 'size' may be used uninitialized [-Werror=maybe-uninitialized]
397 | explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { }
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from flatbuffers/tests/test_builder.cpp:1:
flatbuffers/tests/test_builder.h: In function 'void builder_move_assign_after_releaseraw_test(Builder) [with Builder = flatbuffers::FlatBufferBuilder]':
flatbuffers/tests/test_builder.h:63:10: note: 'size' was declared here
63 | size_t size, offset;
| ^~~~
...
In file included from flatbuffers/tests/test_builder.cpp:1:
flatbuffers/tests/test_builder.h: In function 'void builder_move_assign_after_releaseraw_test(Builder) [with Builder = GrpcLikeMessageBuilder]':
flatbuffers/tests/test_builder.h:63:10: note: 'size' was declared here
63 | size_t size, offset;
| ^~~~
cc1plus: all warnings being treated as errors
Here is the relevant bit of test:
template<class Builder>
void builder_move_assign_after_releaseraw_test(Builder b1) {
auto root_offset1 = populate1(b1);
b1.Finish(root_offset1);
size_t size, offset;
std::shared_ptr<uint8_t> raw(
b1.ReleaseRaw(size, offset), [size](uint8_t *ptr) {
flatbuffers::DefaultAllocator::dealloc(ptr, size);
});
Note how `b1.ReleaseRaw(size, offset)` is expected to populate `size`
and `[size](uint8_t *ptr) {` captures the result. But both are parameters
to the same function call and thus evaluation order is unspecified.
---
tests/test_builder.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/test_builder.h b/tests/test_builder.h
index 6d97ac00..75338b04 100644
--- a/tests/test_builder.h
+++ b/tests/test_builder.h
@@ -61,8 +61,10 @@ void builder_move_assign_after_releaseraw_test(Builder b1) {
auto root_offset1 = populate1(b1);
b1.Finish(root_offset1);
size_t size, offset;
+
+ uint8_t *rr = b1.ReleaseRaw(size, offset);
std::shared_ptr<uint8_t> raw(
- b1.ReleaseRaw(size, offset), [size](uint8_t *ptr) {
+ rr, [size](uint8_t *ptr) {
flatbuffers::DefaultAllocator::dealloc(ptr, size);
});
Builder src;
--
2.39.1