Commit b62a6a13b2f9a40e6ea4bf7bc2a9255429fb0bd6

Carlos Martín Nieto 2014-07-25T08:25:41

array: mark the array to grow as volatile This works around strict aliasing rules letting some versions of GCC (particularly on RHEL 6) thinking that they can skip updating the size of the array when calculating the next element's offset.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/array.h b/src/array.h
index f8a4872..af9eafa 100644
--- a/src/array.h
+++ b/src/array.h
@@ -44,7 +44,7 @@ typedef git_array_t(char) git_array_generic_t;
 /* use a generic array for growth so this can return the new item */
 GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
 {
-	git_array_generic_t *a = _a;
+	volatile git_array_generic_t *a = _a;
 	uint32_t new_size = (a->size < 8) ? 8 : a->asize * 3 / 2;
 	char *new_array = git__realloc(a->ptr, new_size * item_size);
 	if (!new_array) {