From 1fcba7fcea462d67379c8d289bd7e0ad52170e02 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 6 Sep 2024 08:49:44 +0200 Subject: Patch up spurious warning --- configure.sh | 5 ++--- src/core/moves.h | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/configure.sh b/configure.sh index 2b68478..34da488 100755 --- a/configure.sh +++ b/configure.sh @@ -27,9 +27,8 @@ esac STD="-std=c99" WFLAGS="-pedantic -Wall -Wextra" -# -Wstringop-overflow seems to be causing problems when combined with -O3 -# Someone else complained here: https://access.redhat.com/solutions/6755371 -WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-stringop-overflow" +WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-unknown-pragmas" + [ "$ARCH" = "AVX2" ] && AVX="-mavx2" [ -n "$(detectsan address)" ] && ADDR="-fsanitize=address" [ -n "$(detectsan undefined)" ] && UNDEF="-fsanitize=undefined" diff --git a/src/core/moves.h b/src/core/moves.h index 3f285fb..f0d7646 100644 --- a/src/core/moves.h +++ b/src/core/moves.h @@ -182,6 +182,30 @@ inverse_move(uint8_t m) return m - 2 * (m % 3) + 2; } +/* +GCC has issues when -Wstringop-overflow is used together with O3. It produces +warnings like the following: + +In function 'invertmoves', + inlined from 'solve_h48_appendsolution' at src/solvers/h48/solve.h:81:3, + inlined from 'solve_h48_dfs.isra' at src/solvers/h48/solve.h:139:3: +warning: writing 32 bytes into a region of size 0 [-Wstringop-overflow=] + 197 | ret[i] = inverse_move(moves[nmoves - i - 1]); + | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In function 'solve_h48_dfs.isra': +note: at offset 192 into destination object 'invertedpremoves' of size 20 + 71 | uint8_t invertedpremoves[MAXLEN]; + +Clang does not give any warning. +Someone else complained here: https://access.redhat.com/solutions/6755371 + +To solve this issue temporarily, we use a lower optimization setting for +this function only. + +TODO check if the issue is resolved +*/ +#pragma GCC push_options +#pragma GCC optimize ("O2") STATIC void invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret) { @@ -190,6 +214,7 @@ invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret) for (i = 0; i < nmoves; i++) ret[i] = inverse_move(moves[nmoves - i - 1]); } +#pragma GCC pop_options STATIC int readmoves(const char *buf, int max, uint8_t *ret) -- cgit v1.3