I have got an issue flagged by Coverity that I cannot understand.
I have an itializer:
1686 arrayOfNodeIds componentRefs = (arrayOfNodeIds) {
1687 .size = 2,
1688 .ids = (UA_NodeId[]) { UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY)}
1689 };
member ids holds an array. Then this struct is given to a function:
1707 UA_Server_addInstanceOf_instatiateChildNode(server, &subtypeRefs, &componentRefs, &typedefRefs,
1708 objectRoot, callback, (UA_ObjectTypeNode *) typeDefNode,
1709 UA_TRUE, &instantiatedTypes, handle);
the function dereferences conponentRefs->ids and Coverity flaggs this as access to a local variable outside of scope.
By googling i found a similar issue in one linux driver that was solved by using a memcpy to a stack variable. However, I do not understand the problem at all. Is the initializer of the internal array considered as a scope limiter? The problematic file can be found on github.
P.S.: definition of arrayOfNodeIds:
typedef struct arrayOfNodeIds_s {
UA_Int32 size;
UA_NodeId *ids;
} arrayOfNodeIds;