C6522

warning C6522: invalid size specification: expression must be of integral type

Note

This warning occurs only in code that is using a deprecated version of the source-code annotation language (SAL). We recommend that you port your code to use the latest version of SAL. For more information, see Using SAL Annotations to Reduce C/C++ Code Defects.

This warning indicates that an integral type was expected, but an incorrect data type was used. You can use annotation properties that accept the size of a parameter in terms of another parameter, but you must use correct data type. For a list of annotation properties, see Annotation Properties.

Example

The following code generates this warning:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ValidBytes="c")] char *pc, double c);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(ValidBytes="c")] char *pc, double c);

To correct this warning, use size_t for the ValidBytesParam parameter data type, as shown in the following sample code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ValidBytes="c")] char *pc, size_t c);

// C++  
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(ValidBytes="c")] char *pc, size_t c);