renderdoc: Compilation error on GCC 7.2 (-Werror=format-truncation=)

I’m trying to write an Ebuild for Gentoo (which can hopefully end up in the tree eventually) but noticed that the v1.x branch failed to build with GCC 7.2.

root@skare$ gcc --version
gcc (Gentoo 7.2.0 p1.1) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Build log:

/var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/strings/utf8printf.cpp: In function ‘void ____C_A_T_C_H____T_E_S_T____0()’:
/var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/strings/utf8printf.cpp:1441:21: error: ‘ foo’ directive output truncated writing 4 bytes into a region of size 0 [-Werror=format-truncation=]
     int b = snprintf(bufb, sizeof(bufb), "%d foo", largenum);
             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/cstdio:42,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/ext/string_conversions.h:43,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/basic_string.h:6159,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/string:52,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/api/replay/basic_types.h:31,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/api/replay/renderdoc_replay.h:306,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/common/common.h:31,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/strings/utf8printf.cpp:25:
/usr/include/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output 11 bytes into a destination of size 6
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
/var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/strings/utf8printf.cpp:1507:21: error: ‘__builtin___snprintf_chk’ output truncated before the last format character [-Werror=format-truncation=]
     int b = snprintf(bufb, sizeof(bufb), "foobar %c %d", x, fourtytwo);
             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/cstdio:42,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/ext/string_conversions.h:43,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/basic_string.h:6159,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/string:52,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/api/replay/basic_types.h:31,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/api/replay/renderdoc_replay.h:306,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/common/common.h:31,
                 from /var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999/renderdoc/strings/utf8printf.cpp:25:
/usr/include/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output 12 bytes into a destination of size 11
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
cc1plus: all warnings being treated as errors
make[2]: *** [renderdoc/CMakeFiles/rdoc.dir/build.make:903: renderdoc/CMakeFiles/rdoc.dir/strings/utf8printf.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999-abi_x86_64.amd64'
[ 49%] Built target rdoc_gl
make[2]: Leaving directory '/var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999-abi_x86_64.amd64'
make[1]: *** [CMakeFiles/Makefile2:180: renderdoc/CMakeFiles/rdoc.dir/all] Error 2
make[1]: Leaving directory '/var/tmp/portage/dev-util/renderdoc-9999/work/renderdoc-9999-abi_x86_64.amd64'
make: *** [Makefile:130: all] Error 2

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Ugh GCC sure has some shitty warning behaviour. I’ll need to turn that one off globally since it might appear another time in another file, but for now just stick to using the release build where there’s no warnings-as-errors and you can ignore that one.

btw, you might want to look at setting the BUILD_VERSION_DIST_* cmake variables, see the root CMakeLists.txt as well as renderdoc/api/replay/version.h

OK I still don’t get why I didn’t get the error myself, but I think I see the problem. The warning suppression I put on the file isn’t showing up in your build log - when I went to look at the command lines I ended up with to compare and see what was different, I found I was also missing it.

Looking at the CMakeLists.txt again and I noticed that I moved the file, but didn’t update the separate property-setting line. I really have no idea why cmake wouldn’t warn over mentioning a missing file like that. Can you try with that commit above and see if it fixes things?