Skip to content
Snippets Groups Projects
Commit 7df89506 authored by AKhatskevich's avatar AKhatskevich Committed by Kirill Yukhin
Browse files

test: prevent guard-breaker optimization with LTO

In case of very aggressive optimizations the compiler can
optimize guard-breaker function away and the `unit/guard`
test would fail.
parent e24d1c5e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment