Skip to content

fixed #13734 - FP unsignedLessThanZero for unknown array size#7410

Merged
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
firewave:symdb-arr
Mar 28, 2025
Merged

fixed #13734 - FP unsignedLessThanZero for unknown array size#7410
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
firewave:symdb-arr

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator Author

firewave commented Mar 27, 2025

I think we should also add a symbol database and/or ValueFlow test for this but I do not really understand those tests ...

@chrchr-github
Copy link
Copy Markdown
Collaborator

This should do it (in valueFlowSizeof()):

        code  = "void f() {\n"
                "    int a[N + 1];"
                "    x = sizeof(a) / sizeof(a[0]);\n"
                "}";
        values = tokenValues(code,"/");
        ASSERT_EQUALS(1U, values.size());
        ASSERT_EQUALS(-1, values.back().intvalue);
        ASSERT_EQUALS_ENUM(ValueFlow::Value::ValueKind::Impossible, values.back().valueKind);

Co-authored-by: chrchr-github <chrchr-github@users.noreply.github.com>
@firewave
Copy link
Copy Markdown
Collaborator Author

This should do it (in valueFlowSizeof()):

Thanks a lot!

@firewave firewave marked this pull request as ready for review March 27, 2025 22:24
@chrchr-github chrchr-github merged commit 096a016 into cppcheck-opensource:main Mar 28, 2025
60 checks passed
@firewave firewave deleted the symdb-arr branch March 28, 2025 23:30
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