From 419d8c49bd978a59b8a0619d83cb6ba26b18f970 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 14 Jun 2022 09:38:57 -0400 Subject: [PATCH] configure: disable -Wmaybe-uninitialized gcc produces the following warning at -O2, breaking the CI: CXX msg-iter.lo /home/simark/src/babeltrace/src/plugins/ctf/common/src/msg-iter.cpp: In member function 'virtual void ctf::src::internal::MsgIterItemVisitor::visit(const ctf::src::PktInfoItem&)': /home/simark/src/babeltrace/src/plugins/ctf/common/src/msg-iter.cpp:132:87: error: '*(nonstd::optional_lite::optional::value_type*)((char*)&prevPacketEndDefClkVal + offsetof(nonstd::optio nal_lite::optional,nonstd::optional_lite::optional::contained))' may be used uninitialized [-Werror=maybe-uninitialized] 132 | msg = bt_message_discarded_packets_create_with_default_clock_snapshots( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 133 | _mSelfMsgIter, _mLibStream.libObjPtr(), *prevPacketEndDefClkVal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 134 | *_mPacketBeginDefClkVal); | ~~~~~~~~~~~~~~~~~~~~~~~~ /home/simark/src/babeltrace/src/plugins/ctf/common/src/msg-iter.cpp:76:42: note: '*(nonstd::optional_lite::optional::value_type*)((char*)&prevPacketEndDefClkVal + offsetof(nonstd::optiona l_lite::optional,nonstd::optional_lite::optional::contained))' was declared here 76 | nonstd::optional prevPacketEndDefClkVal = _mPacketEndDefClkVal; | ^~~~~~~~~~~~~~~~~~~~~~ I don't see anything wrong with the code, the compiler just seems unhappy with the fact that the value part of the optional will possibly be uninitialized. I tried to disable -Wmaybe-uninitialized at specific spots, but it's too difficult. We get different spurious warnings on different architectures, at different optimization levels, so it's going to end up as a whack-a-mole game. My previous experience is that this warning generates a lot of noise and rarely leads to real bug fixes anyway. Change-Id: Ia013447ee3659954d010b0c4e29b567bc40b6ee7 Reviewed-on: https://review.lttng.org/c/babeltrace/+/8351 Reviewed-by: Philippe Proulx --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index f1cc77d0..89884d97 100644 --- a/configure.ac +++ b/configure.ac @@ -733,6 +733,7 @@ m4_define([WARN_FLAGS_LIST], [ dnl dnl Ref: https://github.com/swig/swig/issues/1259 -Wno-cast-function-type dnl -Wno-missing-field-initializers dnl + -Wno-maybe-uninitialized dnl ]) # Pass -Werror as an extra flag during the test: this is needed to make the -- 2.34.1