C-Quadratic-Sieve
C-Quadratic-Sieve copied to clipboard
Compiling with -O3 on GCC 12.2.0 results in two compiler warnings
steps to reproduce:
$ gcc main.c -O3 -o qs
In file included from main.c:2:
In function ‘cint_erase’,
inlined from ‘cint_right_shifti’ at cint.c:286:9,
inlined from ‘cint_sqrt.part.0’ at cint.c:536:4:
cint.c:107:34: warning: ‘memset’ specified size between 9223372036854775808 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
107 | num->nat = 1, num->end = memset(num->mem, 0, (num->end - num->mem) * sizeof(h_cint_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘cint_right_shifti’,
inlined from ‘cint_sqrt.part.0’ at cint.c:536:4:
cint.c:278:31: note: destination object allocated here
278 | if (num->end - a > num->mem) {
| ~~~^~~~~
In function ‘cint_erase’,
inlined from ‘cint_right_shifti’ at cint.c:286:9,
inlined from ‘cint_sqrt.part.0’ at cint.c:539:4:
cint.c:107:34: warning: ‘memset’ specified size between 9223372036854775808 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
107 | num->nat = 1, num->end = memset(num->mem, 0, (num->end - num->mem) * sizeof(h_cint_t));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘cint_right_shifti’,
inlined from ‘cint_sqrt.part.0’ at cint.c:539:4:
cint.c:278:31: note: destination object allocated here
278 | if (num->end - a > num->mem) {
| ~~~^~~~~
Version of gcc:
gcc (Debian 12.2.0-14) 12.2.0
The program appears to function normally despite the warnings, and valgrind doesn't detect any memory leaks. The warning doesn't appear with -O2.
Hello. I guess it happens in some dead path that gcc doesn't know is dead. Investigation is ongoing to correct the reported warning, thank you.