Edit

Share via


Warning C6514

Invalid annotation: value of the 'name' property exceeds the size of the array

Remarks

This warning indicates that a property value exceeds the size of the array specified in the parameter being annotated. This warning occurs when the value specified for the annotation property is greater than the actual length of the array being passed.

Code analysis name: BUFFER_SIZE_EXCEEDS_ARRAY_SIZE

Example

The following code generates this warning because the size of the array is 6 but the ValidElementsConst property value is 8:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f( [SA_Pre(Deref=1, ValidElementsConst=8)] char(*matrix) [6] );

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f( [Pre(Deref=1, ValidElementsConst=8)] char(*matrix) [6] );

To correct this warning, make sure the size of specified in ValidElementsConst is less than or equal to the size of the array, as shown in the following sample code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f( [SA_Pre(Deref=1, ValidElementsConst=6)] char(*matrix) [6] );

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f( [Pre(Deref=1, ValidElementsConst=6)] char(*matrix) [6] );