error 5960

PC-lint Plus User Discussion
Post Reply
SeeCwriter

error 5960

Post by SeeCwriter »

I am getting error 5960 for the code below, yet there is nothing in the manual about error 5960.

These are the 2-lines of suspect code:

Code: Select all

  int expBufLen = 32;
  unsigned char expBuf[expBufLen] = {0};
 
This is the error message:

Code: Select all

Misc.cpp  380  error 5960: variable-sized object may not be initialized
  unsigned char expBuf[expBufLen] = {0};
                       ^~~~~~~~~
I don't understand why I'm getting this error.
I'm using PC-lint Plus v1.4.1 Beta1. It does the same with v1.4 release.
Michael Metivier

Re: error 5960

Post by Michael Metivier »

From the PC-Lint Plus manual:

"Messages in the 4xxx and 5xxx range are used by PC-lint Plus to report clang compiler errors."

PC-Lint Plus uses clang under the hood to do things like parse your code, so this messages is actually coming from the underlying clang implementation rather than from PC-Lint Plus directly.

So, either clang's C++ (based on your .cpp file extension) analysis is not allowing VLA's as they are not a part of the standard language, or you're in C99 land, in which case initialization of this form is forbidden by the language standard: "The type of the entity to be initialized shall be an array of unknown size or an object type that is not a variable length array type."
Post Reply