Not reported (false negative):
typedef unsigned char u8;
static int f(const u8 *d, int n);
int g(void) { u8 a[4] = {0}; return f(a, 4); }
Command: cppcheck --enable=style --std=c99 test.c
It is also reported for uint8_t (from <stdint.h>) and when the type is unknown.
Expected: constVariable for the typedef case too.</stdint.h>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cppcheck 2.22.0 reports "can be declared as const array" for an array of
unsigned char, but not when the element type is a typedef of unsigned char.
Reported (expected):
static int f(const unsigned char *d, int n);
int g(void) { unsigned char a[4] = {0}; return f(a, 4); }
Not reported (false negative):
typedef unsigned char u8;
static int f(const u8 *d, int n);
int g(void) { u8 a[4] = {0}; return f(a, 4); }
Command: cppcheck --enable=style --std=c99 test.c
It is also reported for uint8_t (from <stdint.h>) and when the type is unknown.
Expected: constVariable for the typedef case too.</stdint.h>
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/15167