Compilation warning when compiling with gcc -Wsign-conversion
-Wsign-conversion
This is a quite aggressive gcc compiler warning, but it often detects issues so sometimes we test builds with it switched on.
Because the concurrentqueue is header-only the warning permeates across the build.
Obviously we can silence this via various means, but it is relatively straight-forward to perform the relevant casts in the code.
The warning occurs on the few lines performing differences with division, such as 2021 and 2965:
auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(blockBaseIndex - headBase) / BLOCK_SIZE);
The warning is emitted due to the signed result of blockBaseIndex - headBase being mixed with the unsigned BLOCK_SIZE.
Casting BLOCK_SIZE to a signed type would be one possible fix.
(g++ 11.2.1)
Let me know if there are more unresolved warnings, I don't have the exact same version of GCC locally.
Looks good. Same warnings appeared on gcc 11.3 when I tried on godbolt. All clean with latest master: https://godbolt.org/z/MdKKf3zGP
Thanks for the quick update, and for sharing your work.