Skip to content

compiler error: directive output may be truncated writing between 2 and 8 bytes #2572

Closed
@stephanecharette

Description

@stephanecharette

When attempting to build on a 64-bit ARM device (NVIDIA Jetson Xavier NX) I'm getting the following compiler error:

src-json/json.hpp: In member function ‘void nlohmann::detail::serializer<BasicJsonType>::dump_escaped(const string_t&, bool) [with BasicJsonType = nlohmann::basic_json<>]’:
src-json/json.hpp:15935:10: error: ‘%.2X’ directive output may be truncated writing between 2 and 8 bytes into a region of size 3 [-Werror=format-truncation=]
     void dump_escaped(const string_t& s, const bool ensure_ascii)
          ^~~~~~~~~~~~
src-json/json.hpp:15935:10: note: directive argument in the range [0, 2147483647]
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/c++/7/cstdio:42,
                 from /usr/include/c++/7/ext/string_conversions.h:43,
                 from /usr/include/c++/7/bits/basic_string.h:6361,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/fstream:38,
                 from src-common/Project.hpp:11,
                 from src-config/Config.cpp:3:
/usr/include/aarch64-linux-gnu/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output between 3 and 9 bytes into a destination of size 3
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
cc1plus: all warnings being treated as errors

What is the issue you have?

I'm using the "single include" updated a few days ago with the year update, 085d497

I see this problem has been reported in the past, but as a side issue in another ticket, and without resolution: #1117.

Build with the following g++ flags on ARM device:

ADD_DEFINITIONS ("-Wall -Wextra -Werror -Wno-unused-parameter")

Including json.hpp causes our build to fail. Will need to setup exceptions around the json include file.

Which compiler and operating system are you using?

> g++ --version
g++ (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0

> cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"

This is the standard NVIDIA image for the Jetson Xavier NX device.

Which version of the library did you use?

  • latest release version 3.9.1

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions