C6503

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at C6503.

warning C6503: Invalid annotation: references and arrays may not be marked Null=Yes or Null=Maybe

System_CAPS_ICON_note.jpg 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 Null property is incorrectly used on a reference or array type. A reference or array type holds the address of an object and must point to a valid object. Because reference and array types cannot be null, you must correct the error by either removing the Null property or by setting the Null property value to No.

The following code generates this warning:

// C++  
#include <CodeAnalysis\SourceAnnotations.h>  
using namespace vc_attributes;  
class Point  
{  
public:  
    //  members  
};  
  
void f([Pre(Null=Yes)] Point& pt);  

To correct this warning, set the Null property to No as shown in the following code:

// C++  
#include <CodeAnalysis\SourceAnnotations.h>  
using namespace vc_attributes;  
  
class Point  
{  
public:  
    //  members  
};   
void f([Pre(Null=No)] Point& pt);  

Annotation Properties

Show: