Closed
Description
This issue was copied from checkedc/checkedc-clang#621
I noticed this issue when converting the Icecast code. In the file src/thread/avl.c
and various others.
The C compiler doesn't complain when a struct variable is not initialized, but the Checked C compiler does. The checked-c-convert
tool doesn't give an warnings that an initialized struct variable was seen.
I created a small example for reference:
Original C code:
typedef struct _link_node {
struct _link_node *parent;
int width;
} link_node;
int add_to_link_node(link_node *node) {
node->width += 5;
return node->width;
}
int main() {
link_node here;
here.width = 10;
return add_to_link_node(&here);
}
checked-c-convert
output:
typedef struct _link_node {
_Ptr<struct _link_node> parent;
int width;
} link_node;
int add_to_link_node(_Ptr<link_node> node) {
node->width += 5;
return node->width;
}
int main() {
link_node here;
here.width = 10;
return add_to_link_node(&here);
}
The checked-c-convert
output will produce the error:
error: struct variable 'here' containing a checked pointer must have an initializer