Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 860 Bytes

c6305.md

File metadata and controls

40 lines (31 loc) · 860 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Warning C6305
Warning C6305
11/04/2016
C6305
SIZEOF_COUNTOF_MISMATCH
__WARNING_SIZEOF_COUNTOF_MISMATCH
C6305
4b3bdf86-b593-425e-89cb-9282878b21bd

Warning C6305

Potential mismatch between sizeof and countof quantities

Remarks

This warning indicates that a variable holding a sizeof result is being added to or subtracted from a pointer or countof expression. This operation will cause unexpected scaling in pointer arithmetic.

Code analysis name: SIZEOF_COUNTOF_MISMATCH

Example

The following code generates this warning:

void f(int *p)
{
  int cb=sizeof(int);
  //code...
  p +=cb; // warning C6305
}

To correct this warning, use the following code:

void f(int *p)
{
  // code...
  p += 1;
}