Warn on and add missing [[noreturn]]

bitcoin/bitcoin: PR #35911

1 minor finding · 1 suggestion

Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Fuzz-harness warning suppression skips clang-cl

In an untested clang-cl Release build with BUILD_FUZZ_BINARY=ON and BUILD_FOR_FUZZING=OFF, the missing suppression is expected to warn on initialize() and fail compilation with CMAKE_COMPILE_WARNING_AS_ERROR=ON.

Location: src/test/fuzz/fuzz.cpp:135 (head).

Details and suggested fix

Both pragma guards test only __GNUC__, which clang-cl does not define, although it accepts #pragma GCC diagnostic. Meanwhile, CMakeLists.txt enables -Wmissing-noreturn outside the MSVC branch and propagates it to test_fuzz. In this configuration, G_FUZZING_BUILD and G_ABORT_ON_FAILED_ASSUME are false, so initialize() always exits and becomes a candidate for the warning. Change both guards to #if defined(__GNUC__) || defined(__clang__). Windows CI does not exercise this combination: its fuzz job enables BUILD_FOR_FUZZING, while its standard job does not enable BUILD_FUZZ_BINARY.


Optional improvements

Link

[suggestion] · Suppression disables -Wmissing-noreturn throughout initialize()

Returning a status for the build-mode rejection would let initialize() and its callbacks remain checked by -Wmissing-noreturn, rather than suppressing the warning even in fuzz and Debug builds.

Location: src/test/fuzz/fuzz.cpp:137 (head).

Details and suggested fix

The build-dependent exit motivates suppressing the warning on initialize(), but the region also covers the CreateSock lambda, which always calls std::terminate() without [[noreturn]]. No build confirmed whether a compiler would diagnose that lambda. Have initialize() return false after printing the build-mode rejection and true after successful initialization, preserving its other exits. Make both LLVMFuzzerInitialize() and main() call std::exit(EXIT_FAILURE) on false. This preserves the rejection message and status while allowing the initializer body to remain outside the suppression. Release builds may still need a smaller suppression region around the entry points; this suggestion does not assume all pragmas can be removed.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.