Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 972 Bytes

c6396.md

File metadata and controls

34 lines (26 loc) · 972 Bytes
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Warning C6396: sizeof('integerConstant') always returns the size of the underlying integer type
Warning C6396
02/05/2024
C6396
SIZEOF_CONSTANT
C6396

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
}