Skip to content

bisect: add another patch (old versions not building with newer compilers) - #9061

Merged
danmar merged 2 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_bisect
Nov 25, 2026
Merged

danmar merged 2 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_bisect

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

Fix build errors with g++ (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review

I found no problems. The only change is to the bisect helper script tools/bisect/bisect_common.py. On the first line of lib/programmemory.cpp the PR puts #include <limits> in front of the existing text. In cppcheck that line is the /* that opens the license header, so the result, #include <limits> /*, is a valid directive and the header compiles. The file is restored by the existing git reset --hard after the build, just like the other patches.

Two side notes, neither confirmed as a bug:

  • The patch only works because line 1 is a comment. If some old revision started programmemory.cpp with a directive, such as #include "programmemory.h", the edited line would become #include <limits> #include .... GCC drops the extra tokens with a warning, which the -w build flag hides, so that include would be lost. I could not check old revisions because there is no git history in the container. sed -i '1i #include <limits>' would avoid the risk.
  • The log message has a typo: programmmemory.

Testing

I did not build cppcheck or testrunner. The PR changes only a Python bisect helper, so neither build would exercise it.

  • python3 -m py_compile tools/bisect/bisect_common.py: passes.
  • I ran the PR's sed command on a copy of pr/lib/programmemory.cpp. Line 1 becomes #include <limits> /*, which is fine.
  • I ran the same sed command on a small file that starts with a /* ... */ comment and uses std::numeric_limits. g++ -c -Wall -Wextra compiles it cleanly.
  • I ran it on a file whose first line is #include <cstdio>. The result is #include <limits> #include <cstdio>, and g++ reports warning: extra tokens at end of #include directive. The second include is lost. This does not affect current cppcheck sources, because their first line is a comment.

Automated review of a6bedd7 by Claude. The pull request was built and tested locally.

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review

I found no new problems. The second commit switched to sed -i '1i #include <limits>', which addresses both side notes from the earlier automated review: the include no longer depends on line 1 being a comment, and the log message typo is gone. The patch is applied before the build and undone by the existing git reset --hard, the same way as the other patches.

Comments

# Comment By Where Status
1 Prepending to line 1 with s/^/ drops the original first line if it is a directive AI review general ✅ Fixed
2 Typo programmmemory in log message AI review general ✅ Fixed

Testing

I did not build cppcheck or testrunner. The PR changes only the Python bisect helper, so neither build would exercise it.

  • I ran the PR's command, sed -i '1i #include <limits>', on a file whose first line is #include "a.h". The result is #include <limits> on a line of its own, followed by the unchanged original lines, so the original first line is kept.
  • I read tools/bisect/bisect_common.py. The new block is guarded by os.path.isfile, so older revisions without lib/programmemory.cpp are skipped. The printed message now reads patching lib/programmemory.cpp.

Automated review of 73e1788 by Claude. The pull request was built and tested locally.

@danmar
danmar merged commit 16486db into cppcheck-opensource:main Nov 25, 2026
74 checks passed
@chrchr-github
chrchr-github deleted the chr_bisect branch November 25, 2026 18:41
@chrchr-github

Copy link
Copy Markdown
Collaborator Author

Thanks for merging. There actually are more problematic commit ranges, so bisecting with gcc >= 13 may still fail due to compilation errors, some of which are not easily patched (see 6f56a95).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants