C6334
warning C6334: sizeof operator applied to an expression with an operator may yield unexpected results
This warning indicates a misuse of the sizeof operator. The sizeof operator, when applied to an expression, yields the size of the type of the resulting expression.
For example, in the following code:
char a[10];
size_t x;
x = sizeof (a - 1);
x will be assigned the value 4, not 9, because the resulting expression is no longer a pointer to the array a, but simply a pointer.
Example
The following code generates this warning:
void f( )
{
size_t x;
char a[10];
x= sizeof (a - 4);
// code...
}
To correct this warning, use the following code:
void f( )
{
size_t x;
char a[10];
x= sizeof (a) - 4;
// code...
}