Skip to content

Commit e13581b

Browse files
committed
Fix build with GCC 11
It seems redundant to array_init() when the structure is zeroed already in the static assignment. But probably the fact that this code juggles between TSTreeCursor and TreeCursor, without using a union, leaves the compiler unable to tell that it's been initialized. Fixes tree-sitter#853
1 parent d5eb596 commit e13581b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/src/tree_cursor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *_cursor) {
448448
TSTreeCursor res = {NULL, NULL, {0, 0}};
449449
TreeCursor *copy = (TreeCursor *)&res;
450450
copy->tree = cursor->tree;
451+
array_init(&copy->stack);
451452
array_push_all(&copy->stack, &cursor->stack);
452453
return res;
453454
}

0 commit comments

Comments
 (0)