diff options
author | Andrew Waterman <andrew@sifive.com> | 2019-08-12 02:33:31 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2019-08-12 02:35:42 -0700 |
commit | bc944193381840386a00ec37a5c44908c8f16689 (patch) | |
tree | f32eb6f63409bf3829d567d2ce0fe0a65d81d46b /util/string.c | |
parent | 0694b85892b49a80eedbe5ac0b558f5a463058a5 (diff) | |
download | pk-bc944193381840386a00ec37a5c44908c8f16689.zip pk-bc944193381840386a00ec37a5c44908c8f16689.tar.gz pk-bc944193381840386a00ec37a5c44908c8f16689.tar.bz2 |
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.
Diffstat (limited to 'util/string.c')
-rw-r--r-- | util/string.c | 5 |
1 files changed, 5 insertions, 0 deletions
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 <stdint.h> #include <ctype.h> +#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; |