I have a similar construct to this snippet in my code
namespace
{
std::atomic<bool> flag(true);
}
void Allocator::deallocate(void* p, const size_t n) //lint !e715 suppress "named parameter 'n' not referenced"
{
if (!flag) { //lint !e774 suppress "boolean condition for 'if' always evaluates to 'false'"
freed += n;
// more code where variable flag may get toggled
}
}
The lint suppressions are currently required on IAR analysis only.
It's probably because the IAR header for std::atomic throws PC-Lint. As a result PC-Lint considers variable flag as something that never changes value, even when the code in this file does (see code comment).
Collaterally, it deems that variable n is never referenced because it is inside "unreachable" code.
This code is x-compiled and no static analysis for other platforms reports these same warnings and errors against this code, suggesting that the root of the problem lies with IAR's header for std::atomic<>.
I have - as an experiment - replaced the std::atomic<bool> with a plain bool. I am then able to remove all the PC-Lint suppressions successfully.
Is there a way I can configure PC-Lint in such a manner that it interprets any instance of std::atomic<T> as just T?