Skip to content

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

Description

@Dologan

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."

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions