Skip to content

Fix #10431 FP one-definition-rule if struct in mutually exclusive #ifdef branches #7584

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

chrchr-github
Copy link
Collaborator

No description provided.

@chrchr-github chrchr-github marked this pull request as ready for review June 11, 2025 08:46
@@ -0,0 +1,6 @@
// #10431
#ifdef X
struct S { int i; }; // cppcheck-suppress unusedStructMember
Copy link
Owner

Choose a reason for hiding this comment

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

shouldn't you add this file odr3.cpp to whole-program_test.py in some places?

Copy link
Owner

Choose a reason for hiding this comment

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

I guess this could become tricky.. but what happens if you have two files..

file1.cpp:

#ifdef X
struct S { int i; }; 
#endif

file2.cpp:

struct S { int i; }; 

These configurations are different but not mutually exclusive.

would it make sense to make sure that if file0 is different then all configurations are considered. If the user don't want to consider all configurations in this case then we can recommend that -D that matches compilation is used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

shouldn't you add this file odr3.cpp to whole-program_test.py in some places?

Absolutely, I must have thought that all files would be checked automatically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These configurations are different but not mutually exclusive.

I have restored the warning in that case.

@chrchr-github chrchr-github marked this pull request as draft June 13, 2025 09:23
@chrchr-github chrchr-github marked this pull request as draft June 13, 2025 09:23
@chrchr-github
Copy link
Collaborator Author

Needs XML handling for --cppcheck-build-dir.

@chrchr-github
Copy link
Collaborator Author

@firewave How do I opt out of the -j2 injection?

@chrchr-github
Copy link
Collaborator Author

@firewave How do I opt out of the -j2 injection?

Guess I found it.

@firewave
Copy link
Collaborator

@firewave How do I opt out of the -j2 injection?

Guess I found it.

Yup. Just provide an existing -j.

Can you please file a ticket about making this work with the builddir? Thanks.

@chrchr-github
Copy link
Collaborator Author

Can you please file a ticket about making this work with the builddir? Thanks.

I don't think there is anything new here, see the existing tests:
@pytest.mark.xfail(strict=True) # no CTU without builddir

@chrchr-github chrchr-github marked this pull request as ready for review June 13, 2025 23:15
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