Skip to content

Commit b62a6a1

Browse files
committed
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 parent 9746b36 commit b62a6a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef git_array_t(char) git_array_generic_t;
4444
/* use a generic array for growth so this can return the new item */
4545
GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
4646
{
47-
git_array_generic_t *a = _a;
47+
volatile git_array_generic_t *a = _a;
4848
uint32_t new_size = (a->size < 8) ? 8 : a->asize * 3 / 2;
4949
char *new_array = git__realloc(a->ptr, new_size * item_size);
5050
if (!new_array) {

0 commit comments

Comments
 (0)