Edit

Share via


Warning C6513

Invalid annotation: ElementSizeConst requires additional size properties

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.

Remarks

This warning indicates that ElementSizeConst requires other properties that are missing from the annotation. Specifying ElementSizeConst alone doesn't provide any benefit to the analysis process. In addition to specifying ElementSize, other properties such as ValidElementsConst or WritableElementsConst must also be specified.

Code analysis name: ELEMENT_SIZE_WITHOUT_BUFFER_SIZE

Example

The following code generates this warning:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ElementSizeConst=4)] void* pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(ElementSizeConst=4)] void* pc);

To correct this warning, use the following code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ElementSizeConst=4, ValidElementsConst=2)] void* pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(ElementSizeConst=4, ValidElementsConst=2)] void* pc);

Incorrect use of ElementSize property also generates this warning.

See also

Using SAL Annotations to reduce code defects