https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122555
Bug ID: 122555
Summary: error: variable '' set but not used
[-Werror=unused-but-set-variable=]
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: rudi at heitbaum dot com
Target Milestone: ---
Compiling nss-3.117 with gcc-16-20251005 results in the following false error.
The following snippet fails compile. If I add “if (calcThreads){}” outside the
for loop, the error does not occur. So believe that the gcc parser is not
marking the use with in the for loop as use.
int calcThreads=0;
for (i = 0; i < threadNum; i++, calcThreads++) {
PR_JoinThread(threadsArr[i]);
if (runDataArr[i]->status != SECSuccess) {
const char *errStr = SECU_Strerror(runDataArr[i]->errNum);
fprintf(stderr, "Thread %d: Error in RSA operation: %d : %s\n",
i, runDataArr[i]->errNum, errStr);
calcThreads -= 1;
} else {
iters += runDataArr[i]->iterRes;
}
PORT_Free((void *)runDataArr[i]);
}
make[4]: Entering directory
'/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/nss-3.117/nss/cmd/rsaperf'
/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc
-o
Linux6.18_x86_64_x86_64-libreelec-linux-gnu-gcc-16.0.0_glibc_PTH_64_OPT.OBJ/rsaperf.o
-c -std=c99 -O2 -fPIC -m64 -pipe -ffunction-sections -fdata-sections
-DHAVE_STRERROR -DLINUX -Dlinux -Wall -Wshadow -Werror -DXP_UNIX -DXP_UNIX
-UDEBUG -DNDEBUG -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE
-DSDB_MEASURE_USE_TEMP_DIR -D_REENTRANT -UDEBUG -DNDEBUG -D_DEFAULT_SOURCE
-D_BSD_SOURCE -D_POSIX_SOURCE -DSDB_MEASURE_USE_TEMP_DIR -D_REENTRANT
-DNSS_DISABLE_SSE3 -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY
-DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES
-DNSS_FIPS_DISABLED -DNSS_USE_STATIC_LIBS -I../../nss/lib/softoken
-I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/nspr
-I../../../dist/Linux6.18_x86_64_x86_64-libreelec-linux-gnu-gcc-16.0.0_glibc_PTH_64_OPT.OBJ/include
-I../../../dist/public/nss -I../../../dist/private/nss
-I../../../dist/public/dbm -I../../../dist/public/seccmd rsaperf.c
rsaperf.c: In function 'main':
rsaperf.c:346:9: error: variable 'calcThreads' set but not used
[-Werror=unused-but-set-variable=]
346 | int calcThreads = 0;
| ^~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [../../coreconf/rules.mk:286:
Linux6.18_x86_64_x86_64-libreelec-linux-gnu-gcc-16.0.0_glibc_PTH_64_OPT.OBJ/rsaperf.o]
Error 1
make[4]: Leaving directory
'/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/nss-3.117/nss/cmd/rsaperf'
make[3]: *** [../coreconf/rules.mk:44: rsaperf] Error 2