Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

C6305

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.

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; 
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.