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

gcc 11.2 compilation warning due to snprintf buffer size #137

Open
chrisguiney opened this issue Nov 21, 2022 · 0 comments
Open

gcc 11.2 compilation warning due to snprintf buffer size #137

chrisguiney opened this issue Nov 21, 2022 · 0 comments

Comments

@chrisguiney
Copy link

chrisguiney commented Nov 21, 2022

I believe the condition was present since initially introduced with 45406d4

It seems like the buffer is too small for the largest potential output. I believe this is a warning in gcc, but it's only sane to compile with -Werror

cd /home/chris/cgrt/build/ext/nanogui && /usr/bin/c++ -DNANOGUI_BUILD -DNANOGUI_SHARED -DNANOGUI_USE_OPENGL -DNVG_BUILD -DNVG_SHARED -DNVG_STB_IMAGE_IMPLEMENTATION -D_GLFW_BUILD_DLL -I/home/chris/cgrt/build/ext/nanogui -I/home/chris/cgrt/ext/nanogui/include -I/home/chris/cgrt/ext/nanogui/ext/nanovg/src -I/home/chris/cgrt/ext/nanogui/ext/glfw/include -Wall -Wextra -g -ggdb -Og -Wall -Werror -fpermissive -fPIC -fvisibility=hidden -march=nehalem -MD -MT ext/nanogui/CMakeFiles/nanogui.dir/src/layout.cpp.o -MF CMakeFiles/nanogui.dir/src/layout.cpp.o.d -o CMakeFiles/nanogui.dir/src/layout.cpp.o -c /home/chris/cgrt/ext/nanogui/src/layout.cpp
In file included from /home/chris/cgrt/ext/nanogui/src/layout.cpp:14:
/home/chris/cgrt/ext/nanogui/include/nanogui/layout.h: In member function ‘nanogui::AdvancedGridLayout::Anchor::operator std::string() const’:
/home/chris/cgrt/ext/nanogui/include/nanogui/layout.h:411:77: error: ‘, ’ directive output may be truncated writing 2 bytes into a region of size between 0 and 10 [-Werror=format-truncation=]
  411 |             snprintf(buf, 50, "Format[pos=(%i, %i), size=(%i, %i), align=(%i, %i)]",
      |                                                                             ^~
/home/chris/cgrt/ext/nanogui/include/nanogui/layout.h:411:31: note: directive argument in the range [0, 255]
  411 |             snprintf(buf, 50, "Format[pos=(%i, %i), size=(%i, %i), align=(%i, %i)]",
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:894,
                 from /usr/include/c++/11/cstdio:42,
                 from /usr/include/c++/11/ext/string_conversions.h:43,
                 from /usr/include/c++/11/bits/basic_string.h:6608,
                 from /usr/include/c++/11/string:55,
                 from /home/chris/cgrt/ext/nanogui/include/nanogui/common.h:21,
                 from /home/chris/cgrt/ext/nanogui/include/nanogui/object.h:15,
                 from /home/chris/cgrt/ext/nanogui/include/nanogui/layout.h:18,
                 from /home/chris/cgrt/ext/nanogui/src/layout.cpp:14:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:71:35: note: ‘__builtin___snprintf_chk’ output between 46 and 58 bytes into a destination of size 50
   71 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   73 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
gmake[3]: *** [ext/nanogui/CMakeFiles/nanogui.dir/build.make:223: ext/nanogui/CMakeFiles/nanogui.dir/src/layout.cpp.o] Error 1
gmake[3]: Leaving directory '/home/chris/cgrt/build'
gmake[2]: *** [CMakeFiles/Makefile2:416: ext/nanogui/CMakeFiles/nanogui.dir/all] Error 2
gmake[2]: Leaving directory '/home/chris/cgrt/build'
gmake[1]: *** [CMakeFiles/Makefile2:790: src/cgrt-cuda/CMakeFiles/cgrt-cuda.dir/rule] Error 2
gmake[1]: Leaving directory '/home/chris/cgrt/build'
gmake: *** [Makefile:377: cgrt-cuda] Error 2
@chrisguiney chrisguiney changed the title gcc 11.2 compilation error on v0.2.0 gcc 11.2 compilation warning due to snprintf buffer size Nov 21, 2022
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