libcint icon indicating copy to clipboard operation
libcint copied to clipboard

Array out of bounds

Open susilehtola opened this issue 4 years ago • 1 comments

Compiling libcint and qcint 4.4.2 gives a GCC warning

/home/susi/fedora/qcint/rawhide/qcint-4.4.2/src/eigh.c: In function '_CINTdiagonalize.part.0':
/home/susi/fedora/qcint/rawhide/qcint-4.4.2/src/eigh.c:847:14: warning: array subscript -1 is outside array bounds of 'double[289]' [-Warray-bounds]
  847 |     wgap[-1] = MAX(0., w[0] - werr[0] - gl);
      |              ^
/home/susi/fedora/qcint/rawhide/qcint-4.4.2/src/eigh.c:1463:12: note: while referencing 'work'
 1463 |     double work[MXRYSROOTS * 9 + 1];
      |            ^~~~

Is this intentional?

susilehtola avatar Jul 15 '21 18:07 susilehtola

The -1 index will not lead to out of boundary. "wgap" points to the middle of the work buffer in all possible cases. I can change it in future release to make compiler happy

sunqm avatar Jul 22 '21 21:07 sunqm