Info 1756

PC-lint Plus User Discussion
Post Reply

Info 1756

Post by SeeCwritwe » Mon Jul 08, 2019 6:14 pm

I have a number of C++ classes that the latest version of PC Lint Plus is now flagging with Info 1756. But I don't understand what I'm supposed to be concerned about.
In the example below, I get this message: "variable 'watchdog' has 'static' storage duration and non-POD type 'c_watchdog'"

class c_watchdog
bool awake;
void Spawn();
void Feed();
void Shoot();
c_watchdog() { awake=false; };
extern c_watchdog watchdog;


Re: Info 1756

Post by mmetivier » Wed Jul 10, 2019 1:00 pm

Well, Rule 1756 says it's supporting AUTOSAR C++ Rule A3-3-2 and that rule says

Using global and static variables of a non-POD type makes the API of a class to bespurious about its true dependencies, as they can be accessed from any place of thesource code. Using static or global variables makes the code more difficult to maintain,less readable and significantly less testable.Another problem is that the order in which constructors and initializers for staticvariables are called is only partially specified in the C++ Language Standard and caneven change from build to build. This can cause issues that are difficult to find or debug.Note that the rule applies to:
•global variables (i.e. extern)
•static variables
•static class member variables
•static function-scope variables

and the text of Rule 1756 specifically calls out that the non-specified order of construction across modules can lead to "subtle errors", most likely if there are dependencies between constructions. In this case, probably not so much, but it *is* a blanket prohibition, so here we are...

Post Reply