Repository navigation
Fix #15277 FP missingReturn: std::unreachable() is not configured as noreturn - #9081
Open
autoantwort wants to merge 1 commit into
Open
autoantwort wants to merge 1 commit into
autoantwort wants to merge 1 commit into
Conversation
…noreturn std::unreachable() (C++23) is declared [[noreturn]], but std.cfg had no entry for it, so a function ending in std::unreachable() was reported as missing a return statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmcppcheck
reviewed
Nov 27, 2026
dmcppcheck
left a comment
Contributor
There was a problem hiding this comment.
AI review
I found no problems. The new std::unreachable noreturn entry in std.cfg works and matches how std::terminate and std::abort are configured. The new tests in test/cfg/std.cpp are inside #ifdef __cpp_lib_unreachable, but cppcheck still checks them because the cfg tests run with --force. The tests fail without the cfg change and pass with it.
Testing
- I built
cppcheckinpr/and inbase/. Both builds succeeded. - cfg test: I ran
test/cfg/std.cppwith the same options thattest/cfg/runtests.shuses (--check-library --force --inline-suppr --check-level=exhaustive ...).- With the PR's
std.cfgthere was no output. - With the base
std.cfgit reportsmissingReturnat line 120, an unmatchedunreachableCodesuppression at line 114, andcheckLibraryNoReturn/checkLibraryFunctionforstd::unreachable(). So the new tests do catch a regression. - g++ 13 with
-std=c++2adoes not define__cpp_lib_unreachable, so the compiler syntax check skips the new block. That is harmless.
- With the PR's
- Own test (
scratch/t.cpp), using the cppcheck of the PR and the base build:#include <utility> int f1(int x) { switch (x) { case 0: return 1; default: std::unreachable(); } } int f2(int x) { if (x) return 1; ::std::unreachable(); } using namespace std; int f3(int x) { if (x) return 1; unreachable(); } int f4(int x) { if (x) return 1; else std::unreachable(); } int f5(int *p) { if (!p) std::unreachable(); return *p; }
- Base reports
missingReturnfor f2 and f4, and an inconclusivenullPointerRedundantCheckfor f5. - The PR reports none of these, and adds no new warnings for this file.
--check-libraryreports nothing forstd::unreachableany more.
- Base reports
cfg/std.cfgis still well-formed XML. I could not validate it against the RelaxNG schema becausexmllintis not installed. I did not runtestrunner, because the PR only changes a cfg file and a cfg test.
Automated review of 0ec2f28 by Claude. The pull request was built and tested locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac: https://trac.cppcheck.net/ticket/15277
Cause:
cfg/std.cfghas no entry forstd::unreachable()(C++23,[[noreturn]] void unreachable();), so it is treated as a function that returns.gnu.cfgalready configures__builtin_unreachableas noreturn.Fix: configure
std::unreachableas noreturn instd.cfg. The new tests intest/cfg/std.cpp(missingReturn and unreachableCode) fail without it.Verification:
make checkcfgandtestrunnerpass. On the real code file the missingReturn FP is gone.This PR was created by Claude Code (an AI coding agent) on behalf of @autoantwort.
🤖 Generated with Claude Code