You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mikir
changed the title
Fix for MISRA C++ 2023 rule MISRACPP2023-6_7_1-a Do not declare the local variable with static storage duration
Fix MISRA C++ 2023 rule 6.7.1 "Local variables shall not have static storage duration"
Jun 14, 2024
Observation : We cannot remove static as the function returning a reference . Can we declare static variable in .h file within class scope to have single instance ?
MemoryResource* getNewDeleteResource() noexcept
{
static detail::NewDeleteResource newDeleteResource;
return &newDeleteResource;
}
I'm afraid that we could get into problems with initialization of such static class variable. This way we ensure that get_default_resource returns pointer to already initialized resource even when it's used before main.
Zserio version and language
Zserio: latest from master
Commit date: 6 days ago (6/4/2024 7:12:28 PM)
Commit hash: b8cc6c0
Describe the bug
2 Misra warnings are getting reported for rule MISRACPP2023-6_7_1-a
1 static MemoryResource* defaultResource = getNewDeleteResource();
<style> </style>2 static detail::NewDeleteResource newDeleteResource;
Please check possibility of fixing the same.
Steps to reproduce the behavior:
SCA run using MISRA 2023 configuration.
Expected behavior
No SCA warnings for MISRA 2023 ruleset
Additional context
N.A
@Roland-Homeier @mikir FYI.
The text was updated successfully, but these errors were encountered: