From bc944193381840386a00ec37a5c44908c8f16689 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 12 Aug 2019 02:33:31 -0700 Subject: Prevent memset from calling itself With -ftree-loop-distribute-patterns, GCC detects that the body of memset is equivalent to memset, and so turns it into a call to memset, causing infinite recursion. Closes #170. --- util/string.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util') diff --git a/util/string.c b/util/string.c index 615c325..90d7127 100644 --- a/util/string.c +++ b/util/string.c @@ -4,6 +4,11 @@ #include #include +#ifdef __GNUC__ +// Don't let GCC pattern-match these functions' bodies into self-calls +#pragma GCC optimize ("no-tree-loop-distribute-patterns") +#endif + void* memcpy(void* dest, const void* src, size_t len) { const char* s = src; -- cgit v1.1