https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116515

            Bug ID: 116515
           Summary: LTO link time prints warning for system headers
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nunojpg at gmail dot com
  Target Milestone: ---

With the following program:

```
#define FMT_HEADER_ONLY

#include <filesystem>

#include <fmt/std.h>

int main(int, char **argv)
{
    std::filesystem::path p{argv[0]};
    fmt::print("{}", p);
    return 0;
}
```

root@f351f435510a:/# g++ -Wextra -O3 -DNDEBUG -flto=auto main.cpp -isystem
fmt/include
In function 'copy',
    inlined from 'for_each_codepoint' at fmt/include/fmt/format.h:682:13,
    inlined from 'find_escape' at fmt/include/fmt/format.h:1852:21,
    inlined from 'write_escaped_string' at fmt/include/fmt/format.h:1944:30,
    inlined from 'write_escaped_path' at fmt/include/fmt/std.h:105:60,
    inlined from 'format' at fmt/include/fmt/std.h:157:31:
fmt/include/fmt/base.h:1220:31: warning: writing 8 bytes into a region of size
7 [-Wstringop-overflow=]
 1220 |   while (begin != end) *out++ = static_cast<T>(*begin++);
      |    
...

Multiple -Wstringop-overflow warnings are printed for fmt, despite fmt being
included as a system header.

This happens at link time and not compile time, and only when using LTO.

LTO doesn't appear to be respecting system headers tag for hidding warnings.


Tested with:
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
g++ (Debian 14.2.0-1) 14.2.0

Reply via email to