cppcheck 2.10 does not report this, so I cannot use your online demo.
cppcheck 2.11 on my project says: style: Variable 'p' can be declared as pointer to const [constVariablePointer] STRUC2 *p = GetStruc2();
However making "p" const will force "target" be const, so the assignment will fail.
Simple change from: STRUC1 *target = p->items + p->current;
to: STRUC1 *target = &p->items[p->current];
will dismiss the warning from cppcheck.
Best Regards Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
cppcheck 2.11 suggests to use const pointer, where in reality the pointer cannot be const.
Have a program:
cppcheck 2.10 does not report this, so I cannot use your online demo.
However making "p" const will force "target" be const, so the assignment will fail.
Simple change from:
STRUC1 *target = p->items + p->current;
to:
STRUC1 *target = &p->items[p->current];
will dismiss the warning from cppcheck.
Best Regards Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11821