次の方法で共有


C6305

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

warning C6305: potential mismatch between sizeof and countof quantities

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

Example

The following code generates this warning:

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

To correct this warning, use the following code:

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