Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestLibrary: added tests showing failure to detect iterator #6595

Merged
merged 2 commits into from
Jul 20, 2024

Conversation

firewave
Copy link
Collaborator

No description provided.

@firewave
Copy link
Collaborator Author

The problem is that we bail out when there is no link. But containers like std::string which are not typed have no links.

@firewave
Copy link
Collaborator Author

I did not file a ticket because I have no example on how to trigger this. I came across this looking at the code while trying to get in an optimization which I had lying around for a while now.

@firewave firewave changed the title TestLibrary: added tests showing failure to detect iterator of container TestLibrary: added tests showing failure to detect iterator Jul 12, 2024
@firewave
Copy link
Collaborator Author

Please also have a look if we actually have full coverage for that function now. I might have missed a case.

@firewave
Copy link
Collaborator Author

The tests pass on Clang but fail on GCC. This is caused by an uninitialized variable.

@firewave firewave marked this pull request as draft July 12, 2024 12:38
@firewave
Copy link
Collaborator Author

/home/runner/work/cppcheck/cppcheck/test/testlibrary.cpp:979:13: runtime error: load of value 88, which is not a valid value for type 'bool'
    #0 0x55d439bad3c9 in TestLibrary::container() /home/runner/work/cppcheck/cppcheck/test/testlibrary.cpp:979:13
    #1 0x55d439b9719a in TestLibrary::run() /home/runner/work/cppcheck/cppcheck/test/testlibrary.cpp:67:9
    #2 0x55d4395b370b in TestFixture::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /home/runner/work/cppcheck/cppcheck/test/fixture.cpp:356:13
    #3 0x55d4395b42a7 in TestFixture::runTests(options const&) /home/runner/work/cppcheck/cppcheck/test/fixture.cpp:394:23
    #4 0x55d4395bcf13 in main /home/runner/work/cppcheck/cppcheck/test/main.cpp:42:42
    #5 0x7fbe25429d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 490fef8403240c91833978d494d39e537409b92e)
    #6 0x7fbe25429e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: 490fef8403240c91833978d494d39e537409b92e)
    #7 0x55d439584a44 in _start (/home/runner/work/cppcheck/cppcheck/cmake.output/bin/testrunner+0xb4ea44) (BuildId: 662ea55c84ad8e7f49aae9b6da6b8246465b4409)

@firewave
Copy link
Collaborator Author

I filed https://trac.cppcheck.net/ticket/12931 about detecting it ourselves.

Still need to look into why Clang apparently initializes the variable with 0.

@firewave firewave marked this pull request as ready for review July 12, 2024 23:22
@firewave firewave merged commit b0a9aa8 into danmar:main Jul 20, 2024
63 checks passed
@firewave firewave deleted the testlib branch July 20, 2024 09:29
@firewave
Copy link
Collaborator Author

I filed https://trac.cppcheck.net/ticket/13452 about the actual issue.

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.

2 participants