Skip to content

Commit 1a9e7fd

Browse files
fuhlig1dennisklein
authored andcommitted
[legacy] zeromq: fix compilation with gcc13
Compilation of v4.3.4 breaks with gcc13. Backport one commit which fixes the problem.
1 parent 8954bb9 commit 1a9e7fd

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

cmake/legacy.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ list(APPEND packages zeromq)
200200
set(zeromq_version "4.3.4")
201201
ExternalProject_Add(zeromq
202202
GIT_REPOSITORY https://github.com/zeromq/libzmq GIT_TAG v${zeromq_version}
203+
PATCH_COMMAND ${patch} -p1 -i "${CMAKE_SOURCE_DIR}/legacy/zeromq/add_missing_rebind_type.patch"
203204
${CMAKE_DEFAULT_ARGS} CMAKE_ARGS
204205
"-DWITH_PERF_TOOL=ON"
205206
"-DZMQ_BUILD_TESTS=ON"
206207
"-DENABLE_CPACK=OFF"
207-
"-DENABLE_DRAFTS=OFF"
208+
"-DENABLE_DRAFTS=ON"
208209
${LOG_TO_FILE}
209210
${DEPENDS_ON_SOURCE_CACHE}
210211
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
commit 438d5d88392baffa6c2c5e0737d9de19d6686f0d
2+
Author: Sergei Trofimovich <[email protected]>
3+
Date: Tue Dec 20 21:45:16 2022 +0000
4+
5+
src/secure_allocator.hpp: define missing 'rebind' type
6+
7+
`gcc-13` added an assert to standard headers to make sure custom
8+
allocators have intended implementation of rebind type instead
9+
of inherited rebind. gcc change:
10+
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=64c986b49558a7
11+
12+
Without the fix build fails on this week's `gcc-13` as:
13+
14+
[ 92%] Building CXX object tests/CMakeFiles/test_security_curve.dir/test_security_curve.cpp.o
15+
In file included from /<<NIX>>/gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:34,
16+
from /<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/stl_uninitialized.h:64,
17+
from /<<NIX>>/gcc-13.0.0/include/c++/13.0.0/memory:69,
18+
from tests/../src/secure_allocator.hpp:42,
19+
from tests/../src/curve_client_tools.hpp:49,
20+
from tests/test_security_curve.cpp:53:
21+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h: In instantiation of 'struct std::__allocator_traits_base::__rebind<zmq::secure_allocator_t<unsigned char>, unsigned char, void>':
22+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:94:11: required by substitution of 'template<class _Alloc, class _Up> using std::__alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = zmq::secure_allocator_t<unsigned char>; _Up = unsigned char]'
23+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:228:8: required by substitution of 'template<class _Alloc> template<class _Tp> using std::allocator_traits< <template-parameter-1-1> >::rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = unsigned char; _Alloc = zmq::secure_allocator_t<unsigned char>]'
24+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:126:65: required from 'struct __gnu_cxx::__alloc_traits<zmq::secure_allocator_t<unsigned char>, unsigned char>::rebind<unsigned char>'
25+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:88:21: required from 'struct std::_Vector_base<unsigned char, zmq::secure_allocator_t<unsigned char> >'
26+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:423:11: required from 'class std::vector<unsigned char, zmq::secure_allocator_t<unsigned char> >'
27+
tests/../src/curve_client_tools.hpp:64:76: required from here
28+
/<<NIX>>/gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A
29+
70 | _Tp>::value,
30+
| ^~~~~
31+
32+
The change adds trivial `rebind` definition with expected return type
33+
and satisfies conversion requirements.
34+
35+
diff --git a/src/secure_allocator.hpp b/src/secure_allocator.hpp
36+
index e0871dcc..5e973689 100644
37+
--- a/src/secure_allocator.hpp
38+
+++ b/src/secure_allocator.hpp
39+
@@ -99,6 +99,17 @@ bool operator!= (const secure_allocator_t<T> &, const secure_allocator_t<U> &)
40+
#else
41+
template <typename T> struct secure_allocator_t : std::allocator<T>
42+
{
43+
+ secure_allocator_t () ZMQ_DEFAULT;
44+
+
45+
+ template <class U>
46+
+ secure_allocator_t (const secure_allocator_t<U> &) ZMQ_NOEXCEPT
47+
+ {
48+
+ }
49+
+
50+
+ template <class U> struct rebind
51+
+ {
52+
+ typedef secure_allocator_t<U> other;
53+
+ };
54+
};
55+
#endif
56+
}

0 commit comments

Comments
 (0)