[tarantool-patches] Re: [tarantool-patches] Re: [PATCH] Suppress -Warray-bounds warning on unit/guard.cc

Alexander Turenko alexander.turenko at tarantool.org
Thu May 16 20:25:36 MSK 2019


Sorry, missed the message. Please, leave me in To or CC, otherwise I can miss a message.

>Среда, 15 мая 2019, 5:31 +03:00 от Konstantin Osipov <kostja at tarantool.org>:
>
>* Alexander Turenko < alexander.turenko at tarantool.org > [19/05/15 04:21]:
>> This warning breaks -Werror -O2 build on GCC 9.1.
>
>Why not fix the code?

I did think that unit/guard.cc really need to look outside of an array
bounds, my bad.

Is the following way to fix is okay (pushed to Totktonada/fix-gcc-9-warnings)?

CCed Georgy.

commit ae705eff77c57dc36149f659b066a6f6abea4d3d
Author: Alexander Turenko <alexander.turenko at tarantool.org>
Date:   Tue May 14 23:28:05 2019 +0300

    Eliminate -Warray-bounds warning on unit/guard.cc
    
    This warning breaks -Werror -O2 build on GCC 9.1.

diff --git a/test/unit/guard.cc b/test/unit/guard.cc
index 24ab1fc2e..a2953b829 100644
--- a/test/unit/guard.cc
+++ b/test/unit/guard.cc
@@ -21,7 +21,7 @@ stack_break_f(char *ptr)
 	 */
 	volatile char sum = 0;
 	memset(block, 0xff, 2048);
-	sum += block[block[4]];
+	sum += block[(unsigned char) block[4]];
 	ptrdiff_t stack_diff = ptr > block ? ptr - block : block - ptr;
 	if (stack_diff < (ptrdiff_t)default_attr.stack_size)
 		sum += stack_break_f(ptr);


More information about the Tarantool-patches mailing list