Some compilation fixes
vonbrand opened this issue · comments
On Fedora 34 the following fixes are needed to build nuweb
. Compiling with CFLAGS='-g -O2 -Wall'
reports some unused variables, I deleted most of them. Attached git patches against frob
(8267eaf), renamed to .txt
to appease github.
A troubling warning I can't fix offhand is:
scraps.c: In function ‘search’:
scraps.c:1316:28: warning: array subscript 1025 is above array bounds of ‘char[1024]’ [-Warray-bounds]
1316 | c = m->prev->chars[SLAB_SIZE - k];
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
scraps.c:6:8: note: while referencing ‘chars’
6 | char chars[SLAB_SIZE];
| ^~~~~
This comes from the piece (at line 6082):
@d Get the nth previous character from a scrap
@{int k = m->index - n - 2;
if (k >= 0)
c = m->scrap->chars[k];
else if (m->prev)
c = m->prev->chars[SLAB_SIZE - k];
@}
It is seen that k
should be 0 here, and the chars
member is defined of size SLAB_SIZE
, so this gives an out of bounds access.
There are some further warnings that I'll dig into later. Perhaps also try latest clang and crank up warnings...
0001-Fix-link-errors-warnings.patch.txt
0002-Propagate-fixes-to-generated-files.patch.txt
0003-Add-nuweb-nuweb-to-.gitignore.patch.txt