Native Recommended Rules rule set

 

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 Native Recommended Rules rule set.

The Native Recommended Rules focus on the most critical and common problems in your native code, including potential security holes and application crashes. You should include this rule set in any custom rule set you create for your native projects. This ruleset is designed to work with Visual Studio Professional edition and higher.

RuleDescription
C6001Using Uninitialized Memory
C6011Dereferencing Null Pointer
C6029Use Of Unchecked Value
C6031Return Value Ignored
C6053Zero Termination From Call
C6054Zero Termination Missing
C6059Bad Concatenation
C6063Missing String Argument To Format Function
C6064Missing Integer Argument To Format Function
C6066Missing Pointer Argument To Format Function
C6067Missing String Pointer Argument To Format Function
C6101Returning uninitialized memory
C6200Index Exceeds Buffer Maximum
C6201Index Exceeds Stack Buffer Maximum
C6214Invalid Cast HRESULT To BOOL
C6215Invalid Cast BOOL To HRESULT
C6216Invalid Compiler-Inserted Cast BOOL To HRESULT
C6217Invalid HRESULT Test With NOT
C6220Invalid HRESULT Compare To -1
C6226Invalid HRESULT Assignment To -1
C6230Invalid HRESULT Use As Boolean
C6235Non-Zero Constant With Logical-Or
C6236Logical-Or With Non-Zero Constant
C6237Zero With Logical-And Loses Side Effects
C6242Local Unwind Forced
C6248Creating Null DACL
C6250Unreleased Address Descriptors
C6255Unprotected Use Of Alloca
C6258Using Terminate Thread
C6259Dead Code In Bitwise-Or Limited Switch
C6260Use Of Byte Arithmetic
C6262Excessive Stack Usage
C6263Using Alloca In Loop
C6268Missing Parentheses In Cast
C6269Pointer Dereference Ignored
C6270Missing Float Argument To Format Function
C6271Extra Argument To Format Function
C6272Non-Float Argument To Format Function
C6273Non-Integer Argumen To Format Function
C6274Non-Character Argument To Format Function
C6276Invalid String Cast
C6277Invalid CreateProcess Call
C6278Array-New Scalar-Delete Mismatch
C6279Scalar-New Array-Delete Mismatch
C6280Memory Allocation-Deallocation Mismatch
C6281Bitwise Relation Precedence
C6282Assignment Replaces Test
C6283Primitive Array-New Scalar-Delete Mismatch
C6284Invalid Object Argument To Format Function
C6285Logical-Or Of Constants
C6286Non-Zero Logical-Or Losing Side Effects
C6287Redundant Test
C6288Mutual Inclusion Over Logical-And Is False
C6289Mutual Exclusion Over Logical-Or Is True
C6290Logical-Not Bitwise-And Precedence
C6291Logical-Not Bitwise-Or Precedence
C6292Loop Counts Up From Maximum
C6293Loop Counts Down From Minimum
C6294Loop Body Never Executed
C6295Infinite Loop
C6296Loop Only Executed Once
C6297Result Of Shift Cast To Larger Size
C6299Bitfield To Boolean Comparison
C6302Invalid Character String Argument To Format Function
C6303Invalid Wide Character String Argument To Format Function
C6305Mismatched Size And Count Use
C6306Incorrect Variable Argument Function Call
C6308Realloc Leak
C6310Illegal Exception Filter Constant
C6312Exception Continue Execution Loop
C6314Bitwise-Or Precedence
C6317Not Not Complement
C6318Exception Continue Search
C6319Ignored By Comma
C6324String Copy Instead Of String Compare
C6328Potential Argument Type Mismatch
C6331VirtualFree Invalid Flags
C6332VirtualFree Invalid Parameter
C6333VirtualFree Invalid Size
C6335Leaking Process Handle
C6381Shutdown Information Missing
C6383Element-Count Byte-Count Buffer Overrun
C6384Pointer Size Division
C6385Read Overrun
C6386Write Overrun
C6387Invalid Parameter Value
C6388Invalid Parameter Value
C6500Invalid Attribute Property
C6501Conflicting Attribute Property Values
C6503References Cannot Be Null
C6504Null On Non-Pointer
C6505MustCheck On Void
C6506Buffer Size On Non-Pointer Or Array
C6507Null Mismatch At Dereference Zero
C6508Write Access On Constant
C6509Return Used On Precondition
C6510Null Terminated On Non-Pointer
C6511MustCheck Must Be Yes Or No
C6513Element Size Without Buffer Size
C6514Buffer Size Exceeds Array Size
C6515Buffer Size On Non-Pointer
C6516No Properties On Attribute
C6517Valid Size On Non-Readable Buffer
C6518Writable Size On Non-Writable Buffer
C6519Invalid annotation: value of the 'NeedsRelease' property must be Yes or No
C6521Invalid Size String Dereference
C6522Invalid Size String Type
C6523Invalid Size String Parameter
C6525Invalid Size String Unreachable Location
C6526Invalid Size String Buffer Type
C6527Invalid annotation: 'NeedsRelease' property may not be used on values of void type
C6530Unrecognized Format String Style
C6540The use of attribute annotations on this function will invalidate all of its existing __declspec annotations
C6551Invalid size specification: expression not parsable
C6552Invalid Deref= or Notref=: expression not parsable
C6701The value is not a valid Yes/No/Maybe value
C6702The value is not a string value
C6703The value is not a number
C6704Unexpected Annotation Expression Error
C6705Expected number of arguments for annotation does not match actual number of arguments for annotation
C6706Unexpected Annotation Error for annotation
C6995Failed to save XML Log file
C26100Race condition
C26101Failing to use interlocked operation properly
C26110Caller failing to hold lock
C26111Caller failing to release lock
C26112Caller cannot hold any lock
C26115Failing to release lock
C26116Failing to acquire or to hold lock
C26117Releasing unheld lock
C26140Concurrency SAL annotation error
C28020The expression is not true at this call
C28021The parameter being annotated must be a pointer
C28022The function class(es) on this function do not match the function class(es) on the typedef used to define it.
C28023The function being assigned or passed should have a _Function_class_ annotation for at least one of the class(es)
C28024The function pointer being assigned to is annotated with the function class, which is not contained in the function class(es) list.
C28039The type of actual parameter should exactly match the type
C28112A variable which is accessed via an Interlocked function must always be accessed via an Interlocked function.
C28113Accessing a local variable via an Interlocked function
C28125The function must be called from within a try/except block
C28137The variable argument should instead be a (literal) constant
C28138The constant argument should instead be variable
C28159Consider using another function instead.
C28160Error annotation
C28163The function should never be called from within a try/except block
C28164The argument is being passed to a function that expects a pointer to an object (not a pointer to a pointer)
C28182Dereferencing NULL pointer. The pointer contains the same NULL value as another pointer did.
C28183The argument could be one value, and is a copy of the value found in the pointer
C28193The variable holds a value that must be examined
C28196The requirement is not satisfied. (The expression does not evaluate to true.)
C28202Illegal reference to non-static member
C28203Ambiguous reference to class member.
C28205_Success_ or _On_failure_ used in an illegal context
C28206Left operand points to a struct, use '->'
C28207Left operand is a struct, use '.'
C28209The declaration for symbol has a conflicting declaration
C28210Annotations for the __on_failure context must not be in explicit pre context
C28211Static context name expected for SAL_context
C28212Pointer expression expected for annotation
C28213The _Use_decl_annotations_ annotation must be used to reference, without modification, a prior declaration.
C28214Attribute parameter names must be p1...p9
C28215The typefix cannot be applied to a parameter that already has a typefix
C28216The checkReturn annotation only applies to postconditions for the specific function parameter.
C28217For function, the number of parameters to annotation does not match that found at file
C28218For function paramteer, the annotation's parameter does not match that found at file
C28219Member of enumeration expected for annotation the parameter in the annotation
C28220Integer expression expected for annotation the parameter in the annotation
C28221String expression expected for the parameter in the annotation
C28222__yes, __no, or __maybe expected for annotation
C28223Did not find expected Token/identifier for annotation, parameter
C28224Annotation requires parameters
C28225Did not find the correct number of required parameters in annotation
C28226Annotation cannot also be a PrimOp (in current declaration)
C28227Annotation cannot also be a PrimOp (see prior declaration)
C28228Annotation parameter: cannot use type in annotations
C28229Annotation does not support parameters
C28230The type of parameter has no member.
C28231Annotation is only valid on array
C28232pre, post, or deref not applied to any annotation
C28233pre, post, or deref applied to a block
C28234__at expression does not apply to current function
C28235The function cannot stand alone as an annotation
C28236The annotation cannot be used in an expression
C28237The annotation on parameter is no longer supported
C28238The annotation on parameter has more than one of value, stringValue, and longValue. Use paramn=xxx
C28239The annotation on parameter has both value, stringValue, or longValue; and paramn=xxx. Use only paramn=xxx
C28240The annotation on parameter has param2 but no param1
C28241The annotation for function on parameter is not recognized
C28243The annotation for function on parameter requires more dereferences than the actual type annotated allows
C28244The annotation for function has an unparseable parameter/external annotation
C28245The annotation for function annotates 'this' on a non-member-function
C28246The parameter annotation for function does not match the type of the parameter
C28250Inconsistent annotation for function: the prior instance has an error.
C28251Inconsistent annotation for function: this instance has an error.
C28252Inconsistent annotation for function: parameter has another annotations on this instance.
C28253Inconsistent annotation for function: parameter has another annotations on this instance.
C28254dynamic_cast<>() is not supported in annotations
C28262A syntax error in the annotation was found in function, for annotation
C28263A syntax error in a conditional annotation was found for Intrinsic annotation
C28264Result lists values must be constants.
C28267A syntax error in the annotations was found annotation in the function.
C28272The annotation for function, parameter when examining is inconsistent with the function declaration
C28273For function, the clues are inconsistent with the function declaration
C28275The parameter to _Macro_value_ is null
C28279For symbol, a 'begin' was found without a matching 'end'
C28280For symbol, an 'end' was found without a matching 'begin'
C28282Format Strings must be in preconditions
C28285For function, syntax error in parameter
C28286For function, syntax error near the end
C28287For function, syntax Error in _At_() annotation (unrecognized parameter name)
C28288For function, syntax Error in _At_() annotation (invalid parameter name)
C28289For function: ReadableTo or WritableTo did not have a limit-spec as a parameter
C28290the annotation for function contains more Externals than the actual number of parameters
C28291post null/notnull at deref level 0 is meaningless for function.
C28300Expression operands of incompatible types for operator
C28301No annotations for first declaration of function.
C28302An extra _Deref_ operator was found on annotation.
C28303An ambiguous _Deref_ operator was found on annotation.
C28304An improperly placed _Notref_ operator was found applied to token.
C28305An error while parsing a token was discovered.
C28306The annotation on parameter is obsolescent
C28307The annotation on parameter is obsolescent
C28350The annotation describes a situation that is not conditionally applicable.
C28351The annotation describes where a dynamic value (a variable) cannot be used in the condition.
Show: