Additional gcc-12 issues
I have encountered two more issues which I believe to be related to gcc-12 (I confirmed that they don't show up when compiling the code on gcc-10).
- When enabling memuse-reports, I get use-after-free warnings in
memuse.h
here and here. This seems to be intentional, however. I can of course disable the warnings on those lines using something like the snippet below, but I'm not sure if that is a proper way to solve this issue, since I can imagine something like that gets messy quickly...
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
...
#pragma GCC diagnostic pop
- When enabling the undefined-sanitizer, I get array-bounds warnings in
cell_convert_part.c
here, here and here. Again, I am not sure what the best way forward is here. These are the exact errors:
cell_convert_part.c: In function 'cell_add_spart':
cell_convert_part.c:218:5: error: 'memmove' offset [0, 127] is out of the bounds [0, 0] [-Werror=array-bounds]
218 | memmove(&c->stars.parts[1], &c->stars.parts[0],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219 | n_copy * sizeof(struct spart));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cell_convert_part.c: In function 'cell_add_sink':
cell_convert_part.c:351:5: error: 'memmove' offset [0, 95] is out of the bounds [0, 0] [-Werror=array-bounds]
351 | memmove(&c->sinks.parts[1], &c->sinks.parts[0],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352 | n_copy * sizeof(struct sink));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cell_convert_part.c: In function 'cell_add_gpart':
cell_convert_part.c:486:5: error: 'memmove' offset [0, 95] is out of the bounds [0, 0] [-Werror=array-bounds]
486 | memmove(&c->grav.parts[1], &c->grav.parts[0],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
487 | n_copy * sizeof(struct gpart));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~