3

I am using C++'s static_assert feature to check things at compile time which usually should pass, e.g:

static_assert( SOME_CONSTANT < 1000u, "..." );

Running PC-lint (version 9.00k) on that code emits note 948: "Operator '<' always evaluates to True", which is kind of pointless for static_asserts.

I know I can either append a //lint !e948 to every static_assert (which is what I do for now) or disable 948 globally, but that would also hide legitimate errors everywhere else.

Is it possible to tell PC-lint to not evaluate/check expressions in static_asserts?

Simon Lehmann
  • 10,737
  • 4
  • 41
  • 53

2 Answers2

0

You can teach PC-Lint to handle static_assert() the same way it handles assert(). Just add the following lines to your code:

#ifdef _lint
//lint -function(__assert, static_assert)
void static_assert(bool, const char*);
#endif
Lars Ljung
  • 375
  • 2
  • 6
0

I added the following line to my .lnt config file to solve this issue.

-dstatic_assert()= // ignore keyword static_assert and following parenthetical

Martin
  • 73
  • 6