Dela via


Code Analysis for C/C++ Warnings

This section lists C/C++ Code Analysis warnings in the range of C6000 to C6999.

In This Section

Warning Number

Description

C6001

warning C6001: using uninitialized memory <variable>

C6011

warning C6011: dereferencing NULL pointer <name>

C6029

warning C6029: possible buffer overrun in call to <function>: use of unchecked value

C6031

warning C6031: return value ignored: <function> could return unexpected value

C6053

warning C6053: call to <function> may not zero-terminate string <variable>

C6054

warning C6054: string <variable> may not be zero-terminated

C6057

warning C6057: buffer overrun due to number of characters/number of bytes mismatch in call to <function>

C6059

warning C6059: Incorrect length parameter in call to <function>. Pass the number of remaining characters, not the buffer size of <variable>

C6063

warning C6063: missing string argument to <function> corresponding to conversion specifier <number>

C6064

warning C6064: missing integer argument to <function> corresponding to conversion specifier <number>

C6066

warning C6066: non-pointer passed as parameter <number> when pointer is required in call to <function>

C6067

warning C6067: parameter <number> in call to <function> must be the address of the string

C6200

warning C6200: index <name> is out of valid index range <min> to <max> for non-stack buffer <variable>

C6201

warning C6201: buffer overrun for <variable>, which is possibly stack allocated: index <name> is out of valid index range <min> to <max>

C6202

warning C6202: buffer overrun for <variable>, which is possibly stack allocated, in call to <function>: length <size> exceeds buffer size <max>

C6203

warning C6203: buffer overrun for buffer <variable> in call to <function>: length <size> exceeds buffer size

C6204

warning C6204: possible buffer overrun in call to <function>: use of unchecked parameter <variable>

C6209

warning C6209: using 'sizeof<variable1>' as parameter <number> in call to <function> where <variable2> may be an array of wide characters, did you intend to use character count rather than byte count?

C6211

warning C6211: Leaking memory <pointer> due to an exception. Consider using a local catch block to clean up memory

C6214

warning C6214: cast between semantically different integer types: HRESULT to a Boolean type

C6215

warning C6215: cast between semantically different integer types: a Boolean type to HRESULT

C6216

warning C6216: compiler-inserted cast between semantically different integral types: a Boolean type to HRESULT

C6217

warning C6217: Implicit cast between semantically different integer types: testing HRESULT with 'not'. Consider using SUCCEEDED or FAILED macro instead

C6219

warning C6219: Implicit cast between semantically different integer types: comparing HRESULT to 1 or TRUE. Consider using SUCCEEDED or FAILED macro instead

C6220

warning C6220 - Implicit cast between semantically different integer types: comparing HRESULT to -1. Consider using SUCCEEDED or FAILED macro instead

C6221

warning C6221: Implicit cast between semantically different integer types: comparing HRESULT to an integer. Consider using SUCCEEDED or FAILED macros instead

C6225

warning C6225: Implicit cast between semantically different integer types: assigning 1 or TRUE to HRESULT. Consider using S_FALSE instead

C6226

warning C6226: Implicit cast between semantically different integer types: assigning -1 to HRESULT. Consider using E_FAIL instead

C6230

warning C6230: implicit cast between semantically different integer types: using HRESULT in a Boolean context

C6235

warning C6235: (<non-zero constant> || <expression>) is always a non-zero constant

C6236

warning C6236: (<expression> || <non-zero constant>) is always a non-zero constant

C6237

warning C6237: (<zero> && <expression>) is always zero. <expression> is never evaluated and may have side effects

C6239

warning C6239: (<non-zero constant> && <expression>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?

C6240

warning C6240: (<expression> && <non-zero constant>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?

C6242

warning C6242: A jump out of this try-block forces local unwind. Incurs severe performance penalty

C6244

warning C6244: local declaration of <variable> hides previous declaration at <line> of <file>

C6246

warning C6246: Local declaration of <variable> hides declaration of same name in outer scope. Additional Information: See previous declaration at <location>.

C6248

warning C6248: setting a SECURITY_DESCRIPTOR’s DACL to NULL will result in an unprotected object

C6250

warning C6250: Calling <function> VirtualFree without the MEM_RELEASE flag may free memory but not address descriptors (VADs); results in address space leaks

C6255

warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _alloca_s instead

C6258

warning C6258: using TerminateThread does not allow proper thread clean up

C6259

warning C6259: labeled code is unreachable: (<expression> & <constant>) in switch-expr cannot evaluate to <case-label>

C6260

warning C6260: sizeof * sizeof is almost always wrong, did you intend to use a character count or a byte count?

C6262

warning C6262: Function uses <constant> bytes of stack: exceeds /analyze:stacksize<constant>. Consider moving some data to heap

C6263

warning C6263: using _alloca in a loop; this can quickly overflow stack

C6268

warning C6268: Incorrect order of operations: (<TYPE1>)(<TYPE2>)x + y. Possible missing parentheses in (<TYPE1>)((<TYPE2>)x + y)

C6269

warning C6269: possible incorrect order of operations: dereference ignored

C6270

warning C6270: missing float argument to <function>: add a float argument corresponding to conversion specifier <number>

C6271

warning C6271: extra argument passed to <function>: parameter <number> is not used by the format string

C6272

warning C6272: non-float passed as argument <number> when float is required in call to <function>

C6273

warning 6273 - non-integer passed as parameter <number> when integer is required in call to <function>: if a pointer value is being passed, %p should be used

C6274

warning C6274: non-character passed as parameter <number> when character is required in call to <function>

C6276

warning C6276: Cast between semantically different string types: char* to wchar_t*. Use of invalid string can lead to undefined behavior

C6277

warning C6277: NULL application name with an unquoted path in call to <function>: results in a security vulnerability if the path contains spaces

C6278

warning C6278: <variable> is allocated with array new [], but deleted with scalar delete. Destructors will not be called

C6279

warning C6279: <variable> is allocated with scalar new, deleted with array delete []

C6280

warning C6280: <variable> is allocated with <function>, but deleted with <function>

C6281

warning 6281 - incorrect order of operations: relational operators have higher precedence than bitwise operators

C6282

warning C6282: Incorrect operator: assignment of constant in Boolean context. Consider using '==' instead

C6283

warning C6283: <variable> is allocated with array new [], but deleted with scalar delete

C6284

warning C6284: object passed as parameter '%d' when string is required in call to <function>.

C6285

warning C6285: (<non-zero constant> || <non-zero constant>) is always a non-zero constant. Did you intend to use the bitwise-and operator?

C6286

warning C6286: (<non-zero constant> || <expression>) is always a non-zero constant. <expression> is never evaluated and may have side effects

C6287

warning C6287: redundant code: the left and right sub-expressions are identical

C6288

warning C6288: Incorrect operator: mutual inclusion over && is always zero. Did you intent to use || instead?

C6289

warning C6289: Incorrect operator: mutual exclusion over || is always a non-zero constant. Did you intend to use && instead?

C6290

warning C6290: Bitwise operation on logical result: ! has higher precedence than &. Use && or (!(x & y)) instead

C6291

warning C6291: Bitwise operation on logical result: ! has higher precedence than |. Use || or (!(x | y)) instead

C6292

warning C6292: ill-defined for-loop: counts up from maximum

C6293

warning C6293: Ill-defined for-loop: counts down from minimum

C6294

warning C6294: Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed

C6295

warning C6295: Ill-defined for-loop: <variable> values are of the range "min" to "max". Loop executed indefinitely

C6296

warning C6296: Ill-defined for-loop: Loop body only executed once

C6297

warning C6297: Arithmetic overflow: 32-bit value is shifted, then cast to 64-bit value. Result may not be an expected value

C6298

warning C6298: using a read-only string <pointer> as a writable string argument: this will attempt to write into static read-only memory and cause random crashes

C6299

warning C6299: explicitly comparing a bit field to a Boolean type will yield unexpected results

C6302

warning C6302: format string mismatch: character string passed as parameter <number> when wide character string is required in call to <function>s

C6303

warning C6303: format string mismatch: wide character string passed as parameter <number> when character string is required in call to <function>

C6305

warning C6305: potential mismatch between sizeof and countof quantities

C6306

warning C6306: incorrect call to <function>: consider using <function> which accepts a va_list as an argument

C6308

warning C6308: 'realloc' may return null pointer: assigning a null pointer to <variable>, which is passed as an argument to 'realloc', will cause the original memory block to be leaked

C6309

warning C6309: argument <number> is null: it does not adhere to function specification of <function>

C6310

warning C6310: illegal constant in exception filter can cause unexpected behavior

C6312

warning C6312: Possible infinite loop: use of the constant EXCEPTION_CONTINUE_EXECUTION in the exception-filter expression of a try-except

C6313

warning C6313: Incorrect operator: Zero-valued flag cannot be tested with bitwise-and. Use an equality test to look for zero-valued flags

C6314

warning C6314: Incorrect order of operations: bitwise-or has higher precedence than the conditional-expression operator. Add parentheses to clarify intent

C6315

warning C6315: Incorrect order of operations: bitwise-and has higher precedence than bitwise-or. Add parentheses to clarify intent

C6316

warning C6316: Incorrect operator: tested expression is constant and non-zero. Use bitwise-and to determine whether bits are set

C6317

warning C6317: incorrect operator: logical-not (!) is not interchangeable with ones-complement (~)

C6318

warning C6318: Ill-defined __try/__except: use of the constant EXCEPTION_CONTINUE_SEARCH or another constant that evaluates to zero in the exception-filter expression. The code in the exception handler block is not executed

C6319

warning C6319: use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects

C6320

warning C6320: exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER. This may mask exceptions that were not intended to be handled

C6322

warning C6322: empty _except block

C6323

warning 6323 - use of arithmetic operator on Boolean type(s)

C6324

warning C6324: potential incorrect use of <function1>: Did you intend to use <function2>?

C6326

warning C6326: potential comparison of a constant with another constant

C6327

warning C6327: Potential buffer overrun: SysAllocStringLen copies <number> characters from the string <variable> without validating the number of characters to copy. The code may crash

C6328

warning C6328:<type> passed as parameter <number> when <type> is required in call to <function>

C6331

warning C6331: Invalid parameter: passing MEM_RELEASE and MEM_DECOMMIT in conjunction to <function> is not allowed. This results in the failure of this call

C6332

warning C6332: Invalid parameter: passing zero as the dwFreeType parameter to <function> is not allowed. This results in the failure of this call

C6333

warning C6333: Invalid parameter: passing MEM_RELEASE and a non-zero dwSize parameter to <function> is not allowed. This results in the failure of this call

C6334

warning C6334: sizeof operator applied to an expression with an operator may yield unexpected results

C6335

warning C6335: leaking process information handle <handlename>

C6336

warning C6336: arithmetic operator has precedence over question operator, use parentheses to clarify intent

C6381

warning C6381: Shutdown API <function> requires a valid dwReason or lpMessage

C6383

warning C6383: buffer overrun due to conversion of an element count into a byte count: an element count is expected for parameter <number> in call to <function>

C6384

warning C6384: dividing sizeof a pointer by another value

C6385

warning C6385: invalid data: accessing <buffer name>, the readable size is <size1> bytes, but <size2> bytes may be read: Lines: x, y

C6386

warning C6386: buffer overrun: accessing <buffer name>, the writable size is <size1> bytes, but <size2> bytes may be written: Lines: x, y

C6387

warning C6387: <argument> may be <value>: this does not adhere to the specification for the function <function name>: Lines: x, y

C6388

warning C6388: <argument> may not be <value>: this does not adhere to the specification for the function <function name>: Lines: x, y

C6400

warning C6400: Using <function name> to perform a case-insensitive compare to constant string <string name>. Yields unexpected results in non-English locales

C6401

warning C6401: Using <function name> in a default locale to perform a case-insensitive compare to constant string < string name>. Yields unexpected results in non-English locales

C6500

warning C6500: invalid annotation: value for <name> property is invalid

C6501

warning C6501: annotation conflict: <name> property conflicts with previously specified property

C6503

warning C6503: annotation conflict: references may not be marked Null=Yes or Null=Maybe

C6504

warning C6504: invalid annotation: property may only be used on values of pointer, pointer-to-member, or array type

C6505

warning C6505: invalid annotation: MustCheck property may not be used on values of void type

C6506

warning C6506: invalid annotation: <name> property may only be used on values of pointer or array types

C6507

warning C6507: annotation conflict: Null property at Deref=0 on a post condition must be a subset of the Null property on the precondition

C6508

warning C6508: invalid annotation: write access is not allowed on const values

C6509

warning C6509: invalid annotation: 'return' cannot be referenced from a precondition

C6510

warning C6510: invalid annotation: NullTerminated property may only be used on values of pointer or array type

C6511

warning C6511: invalid annotation: MustCheck property must be Yes or No

C6512

warning C6512: invalid annotation: Null property must be Maybe if the Valid property is No

C6513

warning C6513: invalid annotation: ElementSizeConst requires additional size properties

C6514

warning C6514: invalid annotation: value of the <name> property exceeds the size of the array

C6515

warning C6515 - invalid annotation: <name> property may only be used on values of pointer type

C6516

warning C6516: invalid annotation: no properties specified for <name> attribute

C6517

warning C6517: annotation conflict: ValidElementsConst and ValidBytesConst may not be specified on the buffers that are not readable

C6518

warning C6518: annotation conflict: WriteableElementsConst and WriteableBytesConst may not be specified on buffers that are not writable

C6521

warning C6521: invalid size specification: * operator can only be applied to pointer types

C6522

warning C6522: invalid size specification: expression must be of integral type

C6523

warning C6523: invalid size specification: parameter <name> not found

C6525

warning C6525: invalid size specification: property value may not be valid

C6526

warning C6526 - invalid size specification: expression must be of array or pointer type

C6530

warning 6530: unrecognized format string style <name>

C6535

warning C6535: buffer cannot be of size <n>, bigger than max(size_t)

See Also

Concepts

Guidelines for Writing Secure Code

Other Resources

Analyzing C/C++ Code Quality by Using Code Analysis