The error only happens for cmake builds, starting with the cmake migration.
Steps to reproduce on Debian/Ubuntu:
- Install packages and clone repo:
( export DEBIAN_FRONTEND=noninteractive && apt update && apt install git ccache make build-essential libtool cmake autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-dev libsqlite3-dev clang llvm -y && git clone https://github.com/bitcoin/bitcoin.git b-c ) && cd b-c git checkout 338bc2cd261ba3daf7fb494f8cb4a534762e292c # cmake migration (allows to test autotools and cmake on the same commit)./autogen.sh && rm -rf ./bld-a && mkdir bld-a && ( cd bld-a && ../configure CC=clang CXX=clang++ --with-sanitizers=undefined && make -j$(nproc) src/bitcoind ) # (passes)rm -rf ./bld-c && cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSANITIZERS=undefined -B ./bld-c && cmake --build ./bld-c -j $(nproc) --target=bitcoind # (fails)