oneTBB
oneTBB copied to clipboard
Compilation fails with gcc-12 with possibly false positive warning
Summary
When compiling the tracy profiler (https://github.com/wolfpld/tracy) on Debian with gcc-12, the following warning is triggered and the compilation fails:
In file included from /usr/include/c++/12/atomic:41,
from /home/marco/projects/tracy/profiler/build/_deps/tbb-src/src/tbb/../../include/oneapi/tbb/detail/_utils.h:22,
from /home/marco/projects/tracy/profiler/build/_deps/tbb-src/src/tbb/address_waiter.cpp:17:
In member function ‘void std::__atomic_base<_IntTp>::store(__int_type, std::memory_order) [with _ITp = bool]’,
inlined from ‘void std::atomic<bool>::store(bool, std::memory_order)’ at /usr/include/c++/12/atomic:104:20,
inlined from ‘void tbb::detail::r1::concurrent_monitor_base<Context>::abort_all_relaxed() [with Context = tbb::detail::r1::address_context]’ at /home/marco/projects/tracy/profiler/build/_deps/tbb-src/src/tbb/concurrent_monitor.h:440:53,
inlined from ‘void tbb::detail::r1::concurrent_monitor_base<Context>::abort_all() [with Context = tbb::detail::r1::address_context]’ at /home/marco/projects/tracy/profiler/build/_deps/tbb-src/src/tbb/concurrent_monitor.h:423:26,
inlined from ‘void tbb::detail::r1::concurrent_monitor_base<Context>::destroy() [with Context = tbb::detail::r1::address_context]’ at /home/marco/projects/tracy/profiler/build/_deps/tbb-src/src/tbb/concurrent_monitor.h:456:24,
inlined from ‘void tbb::detail::r1::clear_address_waiter_table()’ at /home/marco/projects/tracy/profiler/build/_deps/tbb-src/src/tbb/address_waiter.cpp:60:40:
/usr/include/c++/12/bits/atomic_base.h:464:25: error: ‘void __atomic_store_1(volatile void*, unsigned char, int)’ writing 1 byte into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
464 | __atomic_store_n(&_M_i, __i, int(__m));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Version
v2021.12.0
Environment
Provide any environmental details that you consider significant for reproducing the issue. The following information is important:
- OS name and version: Debian 12 bookworm
- Compiler version: gcc-12
Observed Behavior
Compilation fails
Expected Behavior
Compilation succeeds. The following patch could be applied to fix the issue:
diff --git a/src/tbb/CMakeLists.txt b/src/tbb/CMakeLists.txt
index 4003d7b4..6d6d60fc 100644
--- a/src/tbb/CMakeLists.txt
+++ b/src/tbb/CMakeLists.txt
@@ -76,6 +76,10 @@ target_include_directories(tbb
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+if (UNIX)
+ set(TBB_WARNING_SUPPRESS -Wno-stringop-overflow)
+endif()
+
target_compile_options(tbb
PRIVATE
${TBB_CXX_STD_FLAG} # TODO: consider making it PUBLIC.
Steps To Reproduce
- Checkout https://github.com/wolfpld/tracy at v0.11.1
- Run
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release -DLEGACY=1
to configure the build - Run
cmake --build profiler/build --config Release --parallel
to build the project