Closed mmuetzel closed 7 months ago
My SPEX co-authors and I have seen this too. We've looked at it closely and we are fairly sure that it is a spurious warning.
A->scale is an mpq_t type, and so is the input to SPEX_mpq_init. We have also tested this code under valgrind, and it doesn't report any errors.
It's a puzzle as to why some gcc versions (not all) complain about this statement. gcc 9.4.0 and gcc 13.2.0 don't complain, at least on my machine with MPFR 4.2.0, but gcc 11.4.0 does complain in the CI (with MPFR 4.1.0).
That leads me to believe that the warning is spurious.
I tried it with MPFR 4.1.0 and gcc 13.2.0, and got no warnings, on my local machine.
Correction... the function mpq_init is in GMP, not MPFR. SPEX_mpq_init is a simple wrapper around mpq_init, described here: https://gmplib.org/manual/Initializing-Rationals
and it looks to me that we are calling it correctly. sizeof(mpq_t) and sizeof (A->scale) are both 32.
I installed gcc 11.4.0 on my desktop via spack. Using it to compile SPEX causes this warning to be emitted. If instead I use gcc 9.4.0 or gcc 13.2.0 (the latter being the most recent version of gcc on spack), then I get no warning.
I tried -Wstringop-overflow=n for n = 0 to 4 (I think 0 disables the warning but I'm not sure). n=0 makes the warning go away with gcc 11.4.0.
gcc 13.2.0 reports no warning, regardless of the -Wstringop-overflow=n flag, for any n.
Since a more recent gcc is silent about this (13.2.0), and an older gcc complains about it (11.4.0), and a still older gcc is also silent (9.4.0) I think this must be a spurious warning from an overly zealous check in gcc 11.4.0 that is now gone in gcc 13.2.0.
I think it's because of this bug in gcc 11, that was fixed in gcc 12:
I fixed this issue just now, by simply disabling -Wstringop-overflow for gcc 11 when compiling SPEX. See https://github.com/DrTimothyAldenDavis/SuiteSparse/pull/716
I think this is fixed now; I just need to check the CI results.
The logs look fine now.
GCC warns about an out of bounds access in SPEX. See, e.g., the Ubuntu runner in CI:
I don't know if this is a bogus warning or if there is really an out-of-bounds issue.