Skip to content

Fix #13970 cfg/qt.cfg - add definition for QDate::isValid() #7630

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

Merged
merged 1 commit into from
Jun 28, 2025

Conversation

winterz
Copy link
Contributor

@winterz winterz commented Jun 26, 2025

Add the bool isValid() signature.
bool isValid(int, int, int) is already there.

@chrchr-github
Copy link
Collaborator

Does this solve an issue for you? The existing definition already claims to handle both overloads via the default arguments.

@winterz
Copy link
Contributor Author

winterz commented Jun 27, 2025

with the current definition the following code snippet gives a false positive assertWithSideEffect

int IncidenceRecurrence::weekdayCountForMonth(const QDate &date) const
{
    /* cppcheck-suppress assertWithSideEffect */
    Q_ASSERT(date.isValid());

QDate::isValid() doesn't muck with date so it shouldn't cause any side effects, right?

@chrchr-github
Copy link
Collaborator

Then you should add <const/> to the existing definition, and a test case in qt.cpp.

@chrchr-github
Copy link
Collaborator

chrchr-github commented Jun 27, 2025

Side note: The attribute <const/> indicates a constant function, not just member-constness, which seems to be correct in this case. But we might not always interpret this consistently as far as I remember. See #6385

@winterz winterz force-pushed the work/winterz/cfg_qdate_isvalid branch from 1041a92 to a61995c Compare June 28, 2025 20:06
to solve a false positive:
```
 QDate date;
 Q_ASSERT(date.isValid());
```

reports assertWithSideEffect
@winterz winterz force-pushed the work/winterz/cfg_qdate_isvalid branch from a61995c to 2c56f9f Compare June 28, 2025 20:07
@chrchr-github chrchr-github changed the title cfg/qt.cfg - add definition for QDate::isValid() Fix #13970 cfg/qt.cfg - add definition for QDate::isValid() Jun 28, 2025
@chrchr-github chrchr-github merged commit ca83f56 into danmar:main Jun 28, 2025
53 of 54 checks passed
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