Coverity detects an undefined identifier while trying to calculate offset of a member in the structure.
typedef struct A
{
uint8_t mem[10];
} A;
size_t offset = offsetof(A, mem); // This line raises the error.
The exact coverity description is "identifier mem is undefined".
I've tried replacing mem with mem[0], mem[], removed typedef from struct A - but nothing seems to solve it. It'll be great if someone has pointers to what could be upsetting coverity.
[Update#1] : I'm using ubuntu 16.04 (kernel - 4.4.0-38-generic) , gcc/g++ 5.4.0, coverity 7.5.1
[Update#2]: A standalone test.c with this structure and following command line options keeps coverity happy:
cov-build --dir . cc -c test.c -o test -Werror -march=corei7 -g -fstrict-aliasing -fstack-protector -fstrict-overflow -Wall -Wextra -Wshadow -Wmissing-prototypes -Wstrict-prototypes -O3 -fomit-frame-pointer -fPIE.
Interestingly, when I compile the whole project, it leads to a bunch of errors for the same lines : UNDEFINED_IDENTIFIER, ROUTINE_NOT_EMITTED, TYPE_IDENTIFIER_NOT_ALLOWED.