Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some compilation fixes #1

Open
vonbrand opened this issue May 9, 2021 · 0 comments
Open

Some compilation fixes #1

vonbrand opened this issue May 9, 2021 · 0 comments

Comments

@vonbrand
Copy link

vonbrand commented May 9, 2021

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

@gmwesiga gmwesiga mentioned this issue Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant