error: objectIndex - The address of local variable 'attributes' is accessed at non-zero index.
#include<vector>namespaceobjectIndexFalsePositive{voidExampleOfObjectIndexFalsePositive(unsignedshortmask1,unsignedshortmask2,unsignedshortmask3){std::vector<unsignedchar>messageBuffer;unsignedshortattributes=0;attributes|=mask1;attributes|=mask2;attributes|=mask3;unsignedchar*charAttributes=reinterpret_cast<unsignedchar*>(&attributes);messageBuffer.push_back(charAttributes[1]);// this should be the second byte of the unsigned short and is validmessageBuffer.push_back(charAttributes[0]);}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using 2.5
error: objectIndex - The address of local variable 'attributes' is accessed at non-zero index.
Another similar example, not sure if it warrants a different issue
Here is a related ticket: https://trac.cppcheck.net/ticket/10154