Warning C6396
sizeof('integerConstant') always returns the size of the underlying integer type
Remarks
This warning indicates where an integral constant is used as a sizeof
argument. Such expression always returns the size of the type of the constant. It's better to write sizeof(type)
instead. This warning catches common typos in buffer offset calculations.
This check ignores character literals because buffer_size += sizeof(UNICODE_NULL)
is a common idiom.
Example
void f()
{
int a = sizeof(5); // C6396 reported here
}
To fix this issue, replace the integral constant with its type:
void f()
{
int a = sizeof(int); // no C6396 reported here
}