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

[Bug] GCC nonnull and format-overflow in r.fill.stats #4472

Open
wenzeslaus opened this issue Oct 7, 2024 · 0 comments
Open

[Bug] GCC nonnull and format-overflow in r.fill.stats #4472

wenzeslaus opened this issue Oct 7, 2024 · 0 comments
Labels
bug Something isn't working C Related code is in C

Comments

@wenzeslaus
Copy link
Member

Describe the bug

Compilation of r.fill.stats complains about "argument 1 null where non-null expected" with -Wnonnull and -Wformat-overflow for an sprintf call in calculate_raster_mode.

To reproduce

Run compilation in the nix develop environment or with -Wformat-overflow= and/or -Wnonnull (using GCC v13?).

Expected behavior

No errors or warnings. Possibly warnings treated as errors in Nix build.

Screenshots

VERSION_NUMBER=8.5.0dev /home/vpetras/Projects/grass/code/grass/dist.x86_64-pc-linux-gnu/utils/g.html2man.py "/home/vpetras/Projects/grass/code/grass/dist.x86_64-pc-linux-gnu/docs/html/r.fill.stats.html" "/home/vpetras/Projects/grass/code/grass/dist.x86_64-pc-linux-gnu/docs/man/man1/r.fill.stats.1"
In file included from /nix/store/wlavaybjbzgllhq11lib6qgr7rm8imgp-glibc-2.39-52-dev/include/stdio.h:980,
                 from main.c:38:
In function 'sprintf',
    inlined from 'calculate_raster_mode' at main.c:1164:9:
/nix/store/wlavaybjbzgllhq11lib6qgr7rm8imgp-glibc-2.39-52-dev/include/bits/stdio2.h:30:10: warning: argument 1 null where non-null expected [-Wnonnull]
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~
/nix/store/wlavaybjbzgllhq11lib6qgr7rm8imgp-glibc-2.39-52-dev/include/bits/stdio2.h:30:10: note: in a call to built-in function '__builtin_sprintf'
/nix/store/wlavaybjbzgllhq11lib6qgr7rm8imgp-glibc-2.39-52-dev/include/bits/stdio2.h:30:10: warning: null destination pointer [-Wformat-overflow=]
rm r.fill.stats.tmp.html
make[4]: Leaving directory '/home/vpetras/Projects/grass/code/grass/raster/r.fill.stats'

System description

  • Our nix develop environment on Ubuntu 22.04.
  • gcc (GCC) 13.3.0 (2023)
  • GRASS GIS 8.5.0dev 573d54a

Additional context

@wenzeslaus wenzeslaus added bug Something isn't working C Related code is in C labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C Related code is in C
Projects
None yet
Development

No branches or pull requests

1 participant