public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/106020] New: Spurious warnings about stringop overflows only with LTO
@ 2022-06-17 21:05 matt at godbolt dot org
  2022-06-17 21:06 ` [Bug lto/106020] " matt at godbolt dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: matt at godbolt dot org @ 2022-06-17 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106020
           Summary: Spurious warnings about stringop overflows only with
                    LTO
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt at godbolt dot org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

When using Howard Hinnant's date library, and GCC 12.1 on x86, and then with
LTO enabled, there are many apparently spurious errors after the read.constprop
pass:

/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function
'read.constprop':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note:
destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};

It has proven tricky to get a smaller case but https://godbolt.org/z/hPaqz7TY1
demonstrates it with an inline version of date.h - a smaller version that
doesn't inline the date library is https://godbolt.org/z/e75YG6ano and the code
amounts to:

std::chrono::system_clock::time_point parse_datetime(const std::string &sv) {
    std::istringstream ss{sv};
    std::chrono::system_clock::time_point tp;
    ss >> date::parse("%FT%T%Z", tp); // ignoring errors for simplicity
    return tp;
}

(though it has to be linked in a separate TU with LTO enabled to trigger the
issues).

I initially filed this as a bug in the date library itself:
https://github.com/HowardHinnant/date/issues/740 but we now believe this is a
compiler issue.

Compiling with GCC 11 or earlier, or with clang, or without LTO doesn't trigger
these warnings.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-05-18 13:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 21:05 [Bug lto/106020] New: Spurious warnings about stringop overflows only with LTO matt at godbolt dot org
2022-06-17 21:06 ` [Bug lto/106020] " matt at godbolt dot org
2022-06-17 21:07 ` matt at godbolt dot org
2022-06-18  5:15 ` [Bug tree-optimization/106020] " pinskia at gcc dot gnu.org
2022-06-18  5:21 ` pinskia at gcc dot gnu.org
2022-06-18 13:45 ` matt at godbolt dot org
2022-06-18 14:02 ` matt at godbolt dot org
2023-05-18  2:57 ` pinskia at gcc dot gnu.org
2023-05-18  2:58 ` [Bug tree-optimization/106020] Spurious warnings about stringop overflows with -march=skylake -O3 pinskia at gcc dot gnu.org
2023-05-18  3:29 ` pinskia at gcc dot gnu.org
2023-05-18  3:40 ` pinskia at gcc dot gnu.org
2023-05-18  3:43 ` pinskia at gcc dot gnu.org
2023-05-18  3:58 ` pinskia at gcc dot gnu.org
2023-05-18 13:23 ` matt at godbolt dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).