Skip to content

Commit d616fbf

Browse files
sunshinecogitster
authored andcommitted
git-compat-util: st_add4: work around gcc 4.2.x compiler crash
Although changes by 5b442c4 (tree-diff: catch integer overflow in combine_diff_path allocation, 2016-02-19) are perfectly valid, they unfortunately trigger an internal compiler error in gcc 4.2.x: combine-diff.c: In function 'diff_tree_combined': combine-diff.c:1391: internal compiler error: Segmentation fault: 11 Experimentation reveals that changing st_add4()'s argument evaluation order is sufficient to sidestep this problem. Although st_add3() does not trigger the compiler bug, for style consistency, change its argument evaluation order to match. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 935de81 commit d616fbf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

git-compat-util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,8 @@ static inline size_t st_add(size_t a, size_t b)
713713
(uintmax_t)a, (uintmax_t)b);
714714
return a + b;
715715
}
716-
#define st_add3(a,b,c) st_add((a),st_add((b),(c)))
717-
#define st_add4(a,b,c,d) st_add((a),st_add3((b),(c),(d)))
716+
#define st_add3(a,b,c) st_add(st_add((a),(b)),(c))
717+
#define st_add4(a,b,c,d) st_add(st_add3((a),(b),(c)),(d))
718718

719719
static inline size_t st_mult(size_t a, size_t b)
720720
{

0 commit comments

Comments
 (0)