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

Warning stringop-overflow with gcc-10.3.0 #3838

Closed
gsjaardema opened this issue Feb 1, 2024 · 2 comments
Closed

Warning stringop-overflow with gcc-10.3.0 #3838

gsjaardema opened this issue Feb 1, 2024 · 2 comments

Comments

@gsjaardema
Copy link
Contributor

I get the following warning when compiling fmt-10.2.1 using g++-10.3.0 with -O3 optimization:

[ 33%] Building CXX object CMakeFiles/fmt.dir/src/format.cc.o
In file included from /fgs/code/TPL/fmt/fmt/include/fmt/format-inl.h:25,
                 from /fgs/code/TPL/fmt/fmt/src/format.cc:8:
In function 'fmt::v10::detail::format_decimal_result<Char*> fmt::v10::detail::format_decimal(Char*, UInt, int) [with Char = char; UInt = unsigned int]',
    inlined from 'constexpr fmt::v10::detail::format_decimal_result<Iterator> fmt::v10::detail::format_decimal(Iterator, UInt, int) [with Char = char; UInt = unsigned int; Iterator = fmt::v10::appender; typename std::enable_if<(! std::is_pointer<typename std::remove_cv<typename std::remove_reference<_Arg>::type>::type>::value), int>::type <anonymous> = 0]' at /fgs/code/TPL/fmt/fmt/include/fmt/format.h:1375:28,
    inlined from 'void fmt::v10::detail::format_hexfloat(Float, int, fmt::v10::detail::float_specs, fmt::v10::detail::buffer<char>&) [with Float = double; typename std::enable_if<(! std::integral_constant<bool, (std::numeric_limits<_Tp>::digits == 106)>::value), int>::type <anonymous> = 0]' at /fgs/code/TPL/fmt/fmt/include/fmt/format.h:3253:23:
/fgs/code/TPL/fmt/fmt/include/fmt/format.h:1331:11: warning: writing 2 bytes into a region of size 0 [-Wstringop-overflow=]
 1331 |     memcpy(dst, src, 2);
      |     ~~~~~~^~~~~~~~~~~~~
/fgs/code/TPL/fmt/fmt/include/fmt/format.h: In function 'void fmt::v10::detail::format_hexfloat(Float, int, fmt::v10::detail::float_specs, fmt::v10::detail::buffer<char>&) [with Float = double; typename std::enable_if<(! std::integral_constant<bool, (std::numeric_limits<_Tp>::digits == 106)>::value), int>::type <anonymous> = 0]':
/fgs/code/TPL/fmt/fmt/include/fmt/format.h:1374:8: note: at offset -2 to object 'buffer' with size 10 declared here
 1374 |   Char buffer[digits10<UInt>() + 1] = {};
      |        ^~~~~~
[ 66%] Building CXX object CMakeFiles/fmt.dir/src/os.cc.o
@gsjaardema
Copy link
Contributor Author

Might be duplicate of #2708

@vitaut
Copy link
Contributor

vitaut commented Feb 1, 2024

Yeah, it's essentially the same issue (a gcc bug). It should be fixed in gcc 11 and in the meantime you could suppress it with FMT_SYSTEM or other means.

@vitaut vitaut closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants