git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] git-compat-util: st_add4: work around gcc 4.2.x compiler crash

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 21, 2016, 04:35 UTC
Message-ID
<1458534958-6956-2-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1458534958-6956-1-git-send-email-sunshine@sunshineco.com>

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 <sunshine@sunshineco.com>
---
 git-compat-util.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index c07e0c1..4743954 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -715,8 +715,8 @@ static inline size_t st_add(size_t a, size_t b)
 		    (uintmax_t)a, (uintmax_t)b);
 	return a + b;
 }
-#define st_add3(a,b,c)   st_add((a),st_add((b),(c)))
-#define st_add4(a,b,c,d) st_add((a),st_add3((b),(c),(d)))
+#define st_add3(a,b,c)   st_add(st_add((a),(b)),(c))
+#define st_add4(a,b,c,d) st_add(st_add3((a),(b),(c)),(d))
 
 static inline size_t st_mult(size_t a, size_t b)
 {
-- 
2.8.0.rc3.240.g104e649
Previous: Eric SunshineNext: Jeff King
Message 2 of 7 in “work around gcc 4.2.x compiler crash”
  1. 0/2 work around gcc 4.2.x compiler crashEric Sunshine, Mar 21, 2016
  2. 1/2 git-compat-util: st_add4: work around gcc 4.2.x compiler crashEric Sunshine, Mar 21, 2016
  3. Jeff KingMar 21, 2016
  4. Christian CouderMar 21, 2016
  5. Eric SunshineMar 21, 2016
  6. Torsten BögershausenMar 21, 2016
  7. 2/2 Revert "config.mak.uname: use clang for Mac OS X 10.6"Eric Sunshine, Mar 21, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.