We have this function prototype:
BNode *b_new_node(const char *name, int pos, int len, const char *val);
Most of the code using this (and similar) code is auto-generated code and looks like this:
b = b_new_node("foo.bar.id.1", 0, 10, some_data);
The function selects a new BNode and copies the string val into it, but it just assigns the member name pointer, for example.
b_strlcpy(new_node->val, val, sizeof new_node->val); new_node->name = name;
This destroys chaos if the first argument is in b_new_node ("foo.bar.id.1", 0, 10, some_data); is not a string literal or otherwise with a static storage duration, but, for example, a buffer on the stack.
In any case, with gcc (other compilers are also interesting), can we check the compilation time so that this argument is passed to static storage?
(of course, an easy way to avoid these possible problems is to copy this argument also to node - the measurements we made with this approach increase the memory requirement by 50% and slow down the program by 10%, so the approach is undesirable).