Repository: spack/spack

Issue:
Installation issue: libzmq@4.3.4%gcc@13.1.0
### Steps to reproduce the issue

```console
$ spack spec -l libzmq@4.3.4%gcc@13.1.0
Input spec
--------------------------------
libzmq@4.3.4%gcc@13.1.0

Concretized
--------------------------------
seswlae  libzmq@=4.3.4%gcc@=13.1.0~docs~drafts+libbsd+libsodium~libunwind build_system=autotools patches=310b8aa,edca864 arch=linux-almalinux8-skylake_avx512
72yjsdc      ^libbsd@=0.11.7%gcc@=13.1.0 build_system=autotools arch=linux-almalinux8-skylake_avx512
azflx4v          ^libmd@=1.0.4%gcc@=13.1.0 build_system=autotools arch=linux-almalinux8-skylake_avx512
qnvhcef      ^libsodium@=1.0.18%gcc@=13.1.0 build_system=autotools arch=linux-almalinux8-skylake_avx512
cikzlhx      ^pkgconf@=1.9.5%gcc@=13.1.0 build_system=autotools arch=linux-almalinux8-skylake_avx512
...
```


### Error message

<details><summary>Error message</summary>

<pre>
In file included from /home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ext/alloc_traits.h:34,
                 from /home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/stl_tree.h:67,
                 from /home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/map:62,
                 from src/metadata.hpp:33,
                 from src/msg.hpp:40,
                 from src/curve_client.cpp:35:
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/alloc_traits.h: In instantiation of 'struct std::__allocator_traits_base::__rebind<zmq::secure_allocator_t<unsigned char>, unsigned char, void>':
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.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]'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.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>]'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.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>'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/stl_vector.h:88:21:   required from 'struct std::_Vector_base<unsigned char, zmq::secure_allocator_t<unsigned char> >'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/stl_vector.h:423:11:   required from 'class std::vector<unsigned char, zmq::secure_allocator_t<unsigned char> >'
src/curve_client_tools.hpp:64:76:   required from here
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A
   70 |                         _Tp>::value,
      |                               ^~~~~
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/alloc_traits.h:70:31: note: 'std::integral_constant<bool, false>::value' evaluates to false
In file included from /home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/ext/alloc_traits.h:34,
                 from /home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/stl_tree.h:67,
                 from /home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/map:62,
                 from src/metadata.hpp:33,
                 from src/msg.hpp:40,
                 from src/curve_server.cpp:35:
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/alloc_traits.h: In instantiation of 'struct std::__allocator_traits_base::__rebind<zmq::secure_allocator_t<unsigned char>, unsigned char, void>':
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.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]'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.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>]'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.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>'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/stl_vector.h:88:21:   required from 'struct std::_Vector_base<unsigned char, zmq::secure_allocator_t<unsigned char> >'
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/stl_vector.h:423:11:   required from 'class std::vector<unsigned char, zmq::secure_allocator_t<unsigned char> >'
src/curve_server.cpp:184:72:   required from here
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A
   70 |                         _Tp>::value,
      |                               ^~~~~
/home/myuser/.local/spack/linux-almalinux8-skylake_avx512/gcc-8.5.0/gcc-13.1.0-ssshtvjgfvn5ngxyg3ogzv3ggwphd5ty/lib/gcc/x86_64-pc-linux-gnu/13.1.0/../../../../include/c++/13.1.0/bits/alloc_traits.h:70:31: note: 'std::integral_constant<bool, false>::value' evaluates to false
</pre></details>


### Information on your system

* **Spack:** 0.20.0.dev0 (f92b5d586ff7c97f461214d4bb4db5ea4783ddeb)
* **Python:** 3.6.8
* **Platform:** linux-almalinux8-skylake_avx512
* **Concretizer:** clingo

### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/11563824/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/11563825/spack-build-out.txt)


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
Building libzmq@master does not show the same error and succeeds.
version 4.3.3 fails as well. Specifying ~libbsd (introduced from 4.3.3 and defaults to true when not on darwin) does not help.
4.3.2 builds fine.
Failure reported also on generic x86_64 rocky8 system.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libzmq/package.py b/var/spack/repos/builtin/packages/libzmq/package.py
--- a/var/spack/repos/builtin/packages/libzmq/package.py
+++ b/var/spack/repos/builtin/packages/libzmq/package.py
@@ -15,6 +15,8 @@ class Libzmq(AutotoolsPackage):
     url = "https://github.com/zeromq/libzmq/releases/download/v4.3.2/zeromq-4.3.2.tar.gz"
     git = "https://github.com/zeromq/libzmq.git"
 
+    maintainers("dennisklein")
+
     version("master", branch="master")
     version("4.3.4", sha256="c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5")
     version("4.3.3", sha256="9d9285db37ae942ed0780c016da87060497877af45094ff9e1a1ca736e3875a2")
@@ -80,6 +82,13 @@ class Libzmq(AutotoolsPackage):
         when="@4.3.4 %gcc@12:",
     )
 
+    # Fix static assertion failure with gcc-13
+    patch(
+        "https://github.com/zeromq/libzmq/commit/438d5d88392baffa6c2c5e0737d9de19d6686f0d.patch?full_index=1",
+        sha256="e15a8bfe8131f3e648fd79f3c1c931f99cd896b2733a7df1760f5b4354a0687c",
+        when="@4.3.3:4.3.4 %gcc@13:",
+    )
+
     def url_for_version(self, version):
         if version <= Version("4.1.4"):
             url = "http://download.zeromq.org/zeromq-{0}.tar.gz"


Test patch: