From 86b83da8c7836484654fbacaf54f764df378a31e Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Thu, 29 Dec 2022 09:15:49 -0300 Subject: [PATCH 3/4] string: Suppress -Wmaybe-unitialized for wordcopy [BZ #19444] The GCC 6+ when compiling for sparc warns that some variables might be used uninitialized. However it does not seem the fact, since the variables are really initialized (and also other targets that use the same code, like powerpc, do not warn about it). So suppress the warning for now. --- string/wordcopy.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/string/wordcopy.c b/string/wordcopy.c index ae5ccd793c..d0cfc22082 100644 --- a/string/wordcopy.c +++ b/string/wordcopy.c @@ -19,7 +19,12 @@ /* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */ #include +#include +/* Check comment of WORDCOPY_FWD_DEST_ALIGNED. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized"); #include +DIAG_POP_NEEDS_COMMENT; /* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to block beginning at DSTP with LEN `op_t' words (not LEN bytes!). @@ -94,7 +99,14 @@ WORDCOPY_FWD_ALIGNED (long int dstp, long int srcp, size_t len) { do8: a0 = ((op_t *) srcp)[0]; + /* Compiling with -O1 may warn that 'a1' in 'do8' switch may be used + uninitialized. However, 'do8' is only reachable through 'case 1', + since all possible modulo values are handling in the initial + switch). */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized"); ((op_t *) dstp)[0] = a1; + DIAG_POP_NEEDS_COMMENT; do7: a1 = ((op_t *) srcp)[1]; ((op_t *) dstp)[1] = a0; @@ -190,6 +202,14 @@ WORDCOPY_FWD_DEST_ALIGNED (long int dstp, long int srcp, size_t len) goto do4; /* No-op. */ } + /* Compiling with -O1 might warn that 'a2' and 'a3' may be used + uninitialized. However, 'do3' (which uses 'a3') is only reachable either + by 'case 0' or 'case 1', which initializes 'a3' (and it is also set at + 'do1' for subsequent loop iterations). This is similar for 'do4' + (which uses 'a2') that is only reachable by 'case 1' which initializes + 'a2'). + Since the usage is within the MERGE macro, we need to disable the warning + on its definition. */ do { do4: @@ -291,7 +311,11 @@ WORDCOPY_BWD_ALIGNED (long int dstp, long int srcp, size_t len) { do8: a0 = ((op_t *) srcp)[7]; + /* Check the comment on WORDCOPY_FWD_ALIGNED. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (6, "-Wmaybe-uninitialized"); ((op_t *) dstp)[7] = a1; + DIAG_POP_NEEDS_COMMENT; do7: a1 = ((op_t *) srcp)[6]; ((op_t *) dstp)[6] = a0; -- 2.34.1