Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.5 KB

c6508.md

File metadata and controls

48 lines (36 loc) · 1.5 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Warning C6508
Warning C6508
11/04/2016
C6508
WRITE_ACCESS_ON_CONST
__WARNING_WRITE_ACCESS_ON_CONST
C6508
ac5b23c8-ab9e-481b-bc97-8404f0b63100

Warning C6508

Invalid annotation: write access is not allowed on const values

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 the Access property specified on a const parameter implies that it can be written to. For constant values, Access=Read is the only valid setting.

Code analysis name: WRITE_ACCESS_ON_CONST

Example

The following code generates this warning:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void fD ([SA_Pre(Deref=1,Access=SA_Write)]const char *pc);

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

To correct this warning, use the following code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(Deref=1,Access=SA_Read)]const char *pc);

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