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 9: special_values_formatter.hpp:43:16: error: 'strlen' argument missing terminating nul #29

Closed
srakitnican opened this issue Jan 22, 2019 · 7 comments

Comments

@srakitnican
Copy link

srakitnican commented Jan 22, 2019

This happens with GCC9, on cbang commit fdd8867

g++ -o build/cbang/enum/CPUExtendedFeature.o -c -std=c++11 -g -Wall -Werror -I/usr/include/v8-3.14/ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_S
OURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rp
m/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-error=parentheses -Wno-deprecated-de
clarations -fPIC -DDEBUG -D_REENTRANT -DHAVE_EXPAT -DHAVE_PTHREADS -DHAVE_LIBSQLITE -DHAVE_V8 -DDEBUG_LEVEL=1 -DUSING_CBANG -Iinclude -Isrc -Isrc/boost src/cba
ng/enum/CPUExtendedFeature.cpp
g++ -o build/cbang/enum/CPUFeature.o -c -std=c++11 -g -Wall -Werror -I/usr/include/v8-3.14/ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat
/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-error=parentheses -Wno-deprecated-declaratio
ns -fPIC -DDEBUG -D_REENTRANT -DHAVE_EXPAT -DHAVE_PTHREADS -DHAVE_LIBSQLITE -DHAVE_V8 -DDEBUG_LEVEL=1 -DUSING_CBANG -Iinclude -Isrc -Isrc/boost src/cbang/enum/
CPUFeature.cpp
In file included from src/boost/boost/date_time/date_facet.hpp:21,
                 from src/boost/boost/date_time/gregorian/gregorian_io.hpp:16,
                 from src/boost/boost/date_time/gregorian/gregorian.hpp:31,
                 from src/boost/boost/date_time/posix_time/time_formatters.hpp:12,
                 from src/boost/boost/date_time/posix_time/posix_time.hpp:24,
                 from src/cbang/time/Time.cpp:42:
src/boost/boost/date_time/special_values_formatter.hpp: In constructor 'boost::date_time::time_facet<time_type, CharT, OutItrT>::time_facet(size_t) [with time_
type = boost::posix_time::ptime; CharT = char; OutItrT = std::ostreambuf_iterator<char, std::char_traits<char> >]':
src/boost/boost/date_time/special_values_formatter.hpp:43:16: error: 'strlen' argument missing terminating nul [-Werror=stringop-overflow=]
   43 |       std::copy(&default_special_value_names[0],
      |       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   44 |                 &default_special_value_names[3],
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |                 std::back_inserter(m_special_value_names));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/boost/boost/date_time/special_values_formatter.hpp:89:70: note: referenced argument declared here
   89 |   const typename special_values_formatter<CharT, OutItrT>::char_type special_values_formatter<CharT, OutItrT>::default_special_value_names[3][17] = {
      |                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


@jcoffland
Copy link
Member

That's an issue with the built-in boost library. Boost is not yet testing with gcc 9.

You could add -Wno-stringop-overflow to your build scripts.

@srakitnican
Copy link
Author

Hmm Fedora compiles boost with GCC9[1], I don't see Fedora using this option [2] or any patches to fix this. Using the suggested compiler option makes it compile without any further errors, though.

Build log: https://kojipkgs.fedoraproject.org//packages/boost/1.69.0/2.fc30/data/logs/x86_64/build.log

[1] https://koji.fedoraproject.org/koji/buildinfo?buildID=1181814
[2] https://src.fedoraproject.org/cgit/rpms/boost.git/tree/boost.spec#n769

@jcoffland
Copy link
Member

I've updated the built-in boost to 1.69.0. Perhaps that works without -Wno-stringop-overflow.

@srakitnican
Copy link
Author

Seems like new version requires additional header I had to install.

g++ -o build/boost/libs/iostreams/src/lzma.o -c -std=c++11 -g -I/usr/include/v8-3.14/ -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-error=parentheses -Wno-deprecated-declarations -fPIC -DDEBUG -D_REENTRANT -DHAVE_EXPAT -DHAVE_PTHREADS -DHAVE_LIBSQLITE -DHAVE_V8 -DDEBUG_LEVEL=1 -DUSING_CBANG -Iinclude -Isrc -Isrc/boost src/boost/libs/iostreams/src/lzma.cpp
src/boost/libs/iostreams/src/lzma.cpp:15:10: fatal error: lzma.h: No such file or directory
   15 | #include <lzma.h>
      |          ^~~~~~~~
compilation terminated.
scons: *** [build/boost/libs/iostreams/src/lzma.o] Error 1
scons: building terminated because of errors.

After I've installed that still the same error showed up.

g++ -o build/cbang/enum/CPUFeature80000001.o -c -std=c++11 -g -Wall -Werror -I/usr/include/v8-3.14/ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_S
OURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rp
m/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-error=parentheses -Wno-deprecated-de
clarations -fPIC -DDEBUG -D_REENTRANT -DHAVE_EXPAT -DHAVE_PTHREADS -DHAVE_LIBSQLITE -DHAVE_V8 -DDEBUG_LEVEL=1 -DUSING_CBANG -Iinclude -Isrc -Isrc/boost src/cba
ng/enum/CPUFeature80000001.cpp
In file included from src/boost/boost/date_time/date_facet.hpp:21,
                 from src/boost/boost/date_time/gregorian/gregorian_io.hpp:16,
                 from src/boost/boost/date_time/gregorian/gregorian.hpp:31,
                 from src/boost/boost/date_time/posix_time/time_formatters.hpp:12,
                 from src/boost/boost/date_time/posix_time/posix_time.hpp:24,
                 from src/cbang/time/Time.cpp:42:
src/boost/boost/date_time/special_values_formatter.hpp: In constructor 'boost::date_time::time_facet<time_type, CharT, OutItrT>::time_facet(size_t) [with time_
type = boost::posix_time::ptime; CharT = char; OutItrT = std::ostreambuf_iterator<char, std::char_traits<char> >]':
src/boost/boost/date_time/special_values_formatter.hpp:43:16: error: 'strlen' argument missing terminating nul [-Werror=stringop-overflow=]
   43 |       std::copy(&default_special_value_names[0],
      |       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   44 |                 &default_special_value_names[3],
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |                 std::back_inserter(m_special_value_names));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/boost/boost/date_time/special_values_formatter.hpp:89:70: note: referenced argument declared here
   89 |   const typename special_values_formatter<CharT, OutItrT>::char_type special_values_formatter<CharT, OutItrT>::default_special_value_names[3][17] = {
      |                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@jcoffland
Copy link
Member

I fixed the lzma.h error.

You noted that Fedora does not add -Wno-stringop-overflow. I can see this is true from the log you linked above, but the log also shows this warning:
libs/log/src/trivial.cpp:77:53: warning: 'strlen' argument missing terminating nul [-Wstringop-overflow=]

A different place but, it's the same error. Building the boost package does not actually build much of boost. Boost is mostly C++ header files that get compiled only when used from other programs.

So Fedora has the same problem and it's not fixed there either.

@srakitnican
Copy link
Author

srakitnican commented Feb 3, 2019

Hmm turns out -Werror is not a standard Fedora compiler flag, turns out this becomes an issue due to me setting the SCons debug flag long time ago. I remember setting it because the resulted binary was not in the wanted format, maybe debuginfo stripped or lacking. Anyway without -Werror cbang compiles fine. Sorry for the noise. CAMotics still fails but that is another issue.

@jcoffland
Copy link
Member

Yes, I use -Werror in debug mode to make sure I fix any compiler warnings.

stephenxs added a commit to stephenxs/sonic-swss that referenced this issue Jan 27, 2021
…iling error on gcc9

Add "-Wno-stringop-overflow" option to avoid the following error:

    orch.cpp: In member function 'ref_resolve_status Orch::resolveFieldRefArray(type_map&, const string&, swss::KeyOpFieldsValuesTuple&, std::vector<long unsigned int>&, std::string&)':
    orch.cpp:609:41: error: 'strlen' argument missing terminating nul [-Werror=stringop-overflow=]
      609 |                     object_name_list += string(&list_item_delimiter);
          |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from orch.cpp:6:
    orch.h:25:12: note: referenced argument declared here
       25 | const char list_item_delimiter = ',';
          |            ^~~~~~~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors

According to CauldronDevelopmentLLC/cbang#29, this is an error from boost and can be suppressed by using this option

Signed-off-by: Stephen Sun <[email protected]>
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

2 participants