aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-09-06 08:49:44 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-09-06 08:49:44 +0200
commit1fcba7fcea462d67379c8d289bd7e0ad52170e02 (patch)
tree20d9fd74a81111ba84099ca215d6723a621b736e
parentf85ac77efc0feeeab183e509a7baca1c507da3c5 (diff)
downloadnissy-core-1fcba7fcea462d67379c8d289bd7e0ad52170e02.tar.gz
nissy-core-1fcba7fcea462d67379c8d289bd7e0ad52170e02.zip
Patch up spurious warning
-rwxr-xr-xconfigure.sh5
-rw-r--r--src/core/moves.h25
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
27 27
28STD="-std=c99" 28STD="-std=c99"
29WFLAGS="-pedantic -Wall -Wextra" 29WFLAGS="-pedantic -Wall -Wextra"
30# -Wstringop-overflow seems to be causing problems when combined with -O3 30WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-unknown-pragmas"
31# Someone else complained here: https://access.redhat.com/solutions/6755371 31
32WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-stringop-overflow"
33[ "$ARCH" = "AVX2" ] && AVX="-mavx2" 32[ "$ARCH" = "AVX2" ] && AVX="-mavx2"
34[ -n "$(detectsan address)" ] && ADDR="-fsanitize=address" 33[ -n "$(detectsan address)" ] && ADDR="-fsanitize=address"
35[ -n "$(detectsan undefined)" ] && UNDEF="-fsanitize=undefined" 34[ -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)
182 return m - 2 * (m % 3) + 2; 182 return m - 2 * (m % 3) + 2;
183} 183}
184 184
185/*
186GCC has issues when -Wstringop-overflow is used together with O3. It produces
187warnings like the following:
188
189In function 'invertmoves',
190 inlined from 'solve_h48_appendsolution' at src/solvers/h48/solve.h:81:3,
191 inlined from 'solve_h48_dfs.isra' at src/solvers/h48/solve.h:139:3:
192warning: writing 32 bytes into a region of size 0 [-Wstringop-overflow=]
193 197 | ret[i] = inverse_move(moves[nmoves - i - 1]);
194 | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195In function 'solve_h48_dfs.isra':
196note: at offset 192 into destination object 'invertedpremoves' of size 20
197 71 | uint8_t invertedpremoves[MAXLEN];
198
199Clang does not give any warning.
200Someone else complained here: https://access.redhat.com/solutions/6755371
201
202To solve this issue temporarily, we use a lower optimization setting for
203this function only.
204
205TODO check if the issue is resolved
206*/
207#pragma GCC push_options
208#pragma GCC optimize ("O2")
185STATIC void 209STATIC void
186invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret) 210invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret)
187{ 211{
@@ -190,6 +214,7 @@ invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret)
190 for (i = 0; i < nmoves; i++) 214 for (i = 0; i < nmoves; i++)
191 ret[i] = inverse_move(moves[nmoves - i - 1]); 215 ret[i] = inverse_move(moves[nmoves - i - 1]);
192} 216}
217#pragma GCC pop_options
193 218
194STATIC int 219STATIC int
195readmoves(const char *buf, int max, uint8_t *ret) 220readmoves(const char *buf, int max, uint8_t *ret)

Generated with cgit - Back to sebastiano.tronto.net