Skip to content

Fix fallthrough warnings

Stefan Roiser requested to merge roiser/Gaudi:fix-fallthrough into master

When building sometimes warning a la

[322/430] Building CXX object GaudiExamples/CMakeFiles/GaudiExamples.dir/src/FunctionalAlgorithms/selector.cpp.o In file included from ../GaudiKernel/GaudiKernel/ContainedObject.h:7, from ../GaudiExamples/GaudiExamples/MyTrack.h:9, from ../GaudiExamples/src/FunctionalAlgorithms/selector.cpp:7: ../GaudiKernel/GaudiKernel/StreamBuffer.h: In member function ‘void StreamBuffer::swapToBuffer(const void*, int)’: ../GaudiKernel/GaudiKernel/StreamBuffer.h:569:9: warning: this statement may fall through [-Wimplicit-fallthrough=] ../GaudiKernel/GaudiKernel/StreamBuffer.h:571:3: note: here

are issued by the compiler. This happens for me when building with distcc. When building without I believe those warnings are not issued, not sure why.

Since C++ 17 there is an attribute [[fallthrough]]; which can be used to overcome this warning when the behavior of fallthrough is wanted. For Gaudi this warning is issued in 3 places

GaudiKernel/GaudiKernel/StreamBuffer.h:569 GaudiKernel/src/Lib/EventSelectorDataStream.cpp:81 RootCnv/src/RootNTupleCnv.cpp:540

each of those contained a comment /* FALLTHROUGH */. I didn't check the code in detail but replaced the comment with the attribute which solves those compiler warnings.

Edited by Marco Clemencic

Merge request reports