V627. Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number.

The analyzer has detected a potential error: a macro expanding into a number serves as an argument for the 'sizeof' operator. Using the operator in such a way can cause allocation of memory amount of incorrect size or other defects.

Consider an example:

#define NPOINT 100
...
char *point = (char *)malloc(sizeof(NPOINT));

Executing this code will result in allocation of insufficient memory amount. This is the correct code:

#define NPOINT 100
...
char *point = (char *)malloc(NPOINT);

This diagnostic is classified as:

You can look at examples of errors detected by the V627 diagnostic.


Bugs Found

Checked Projects
417
Collected Errors
14 279
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept