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

Compilation warning on GCC 11 using -fsanitize=address #3334

Closed
Dologan opened this issue Mar 3, 2023 · 2 comments
Closed

Compilation warning on GCC 11 using -fsanitize=address #3334

Dologan opened this issue Mar 3, 2023 · 2 comments

Comments

@Dologan
Copy link

Dologan commented Mar 3, 2023

Compiling fmt 9.1.0 with GCC 11 using -fsanitize=address and -Werror=stringop-overflow leads to the following error:

fmt-9.1.0/include/fmt/core.h:2096:48: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 2096 |     for (size_t i = 0; i < size; ++i) data_[i] = s[i];

fmt-9.1.0/include/fmt/core.h: In member function 'const Char* fmt::v9::detail::vformat_to(fmt::v9::detail::buffer<T>&, fmt::v9::basic_string_view<Char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<typename std::conditional<std::is_same<typename fmt::v9::type_identity<T>::type, char>::value, fmt::v9::appender, std::back_insert_iterator<fmt::v9::detail::buffer<typename fmt::v9::type_identity<T>::type> > >::type, typename fmt::v9::type_identity<T>::type> >, fmt::v9::detail::locale_ref)::format_handler::on_format_specs(int, const Char*, const Char*) [with Char = char]':
fmt-9.1.0/include/fmt/core.h:2089:8: note: at offset 4 into destination object 'fmt::v9::detail::fill_t<char>::data_' of size 4
 2089 |   Char data_[max_size] = {Char(' '), Char(0), Char(0), Char(0)};
      |        ^~~~~

This code is apparently currently flagged as being a "Workaround an array initialization issue in gcc 4.8."

@vitaut vitaut changed the title Compilation error on GCC 11 using -fsanitize=address Compilation warning on GCC 11 using -fsanitize=address Mar 4, 2023
@vitaut
Copy link
Contributor

vitaut commented Mar 4, 2023

This is a known bug in gcc fixed in trunk but I think we should workaround it considering that many users are affected.

@vitaut
Copy link
Contributor

vitaut commented Mar 18, 2023

Worked around in d9bc5f1.

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