nixpkgs/pkgs/shells/tcsh/avoid-gcc5-wrong-optimisation.patch

29 lines
628 B
Diff
Raw Normal View History

From: christos <christos>
Date: Thu, 28 May 2015 11:47:03 +0000
Subject: [PATCH] avoid gcc-5 optimization malloc + memset = calloc (Fridolin
Pokorny)
---
tc.alloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tc.alloc.c b/tc.alloc.c
index b9aec63..c1cb330 100644
--- a/tc.alloc.c
+++ b/tc.alloc.c
@@ -348,10 +348,13 @@ calloc(size_t i, size_t j)
{
#ifndef lint
char *cp;
+ volatile size_t k;
i *= j;
cp = xmalloc(i);
- memset(cp, 0, i);
+ /* Stop gcc 5.x from optimizing malloc+memset = calloc */
+ k = i;
+ memset(cp, 0, k);
return ((memalign_t) cp);
#else