stringop-overflow warning in 8.1.1 on g++ (GCC) 10.2.1 20200804 · Issue #2708 · fmtlib/fmt · GitHub
Skip to content

stringop-overflow warning in 8.1.1 on g++ (GCC) 10.2.1 20200804 #2708

Description

@andrewkcorcoran
In function ‘copy2’,
    inlined from ‘format_decimal’ at /local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1124:8,
    inlined from ‘format_decimal’ at /local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1134:28,
    inlined from ‘write.constprop’ at /local/1/home/build/gcc/_deps/fmt-src/include/fmt/chrono.h:1663:36:
/local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1090:11: error: writing 2 bytes into a region of size 0 [-Werror=stringop-overflow=]
 1090 |     memcpy(dst, src, 2);
      |           ^
/local/1/home/build/gcc/_deps/fmt-src/include/fmt/chrono.h: In member function ‘write.constprop’:
/local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1133:8: note: at offset -2 to object ‘buffer’ with size 10 declared here
 1133 |   Char buffer[digits10<UInt>() + 1];
      |        ^
In function ‘format_decimal’,
    inlined from ‘format_decimal’ at /local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1134:28,
    inlined from ‘write.constprop’ at /local/1/home/build/gcc/_deps/fmt-src/include/fmt/chrono.h:1663:36:
/local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1120:12: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 1120 |     *--out = static_cast<Char>('0' + value);
      |            ^
/local/1/home/build/gcc/_deps/fmt-src/include/fmt/chrono.h: In member function ‘write.constprop’:
/local/1/home/build/gcc/_deps/fmt-src/include/fmt/format.h:1133:8: note: at offset -1 to object ‘buffer’ with size 10 declared here
 1133 |   Char buffer[digits10<UInt>() + 1];

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