[tarantool-patches] [PATCH v2 1/3] test: prevent guard-breaker optimization with LTO
Alexander Turenko
alexander.turenko at tarantool.org
Mon Oct 15 02:17:29 MSK 2018
From: AKhatskevich <avkhatskevich at tarantool.org>
In case of very aggressive optimizations the compiler can
optimize guard-breaker function away and the `unit/guard`
test would fail.
---
test/unit/guard.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/unit/guard.cc b/test/unit/guard.cc
index 231b44c7d..3d42fee31 100644
--- a/test/unit/guard.cc
+++ b/test/unit/guard.cc
@@ -13,7 +13,11 @@ static int __attribute__((noinline))
stack_break_f(char *ptr)
{
char block[2048];
- char sum = 0;
+ /*
+ * Make sum volatile to prevent a compiler from
+ * optimizing away call to this function.
+ */
+ volatile char sum = 0;
memset(block, 0xff, 2048);
sum += block[block[4]];
ptrdiff_t stack_diff = ptr > block ? ptr - block : block - ptr;
--
2.19.1
More information about the Tarantool-patches
mailing list