From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6977E385843E; Fri, 17 Jun 2022 21:05:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6977E385843E From: "matt at godbolt dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/106020] New: Spurious warnings about stringop overflows only with LTO Date: Fri, 17 Jun 2022 21:05:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: matt at godbolt dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 21:05:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106020 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.const= prop 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::digits10+2u] =3D {= }; It has proven tricky to get a smaller case but https://godbolt.org/z/hPaqz7= TY1 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 tri= gger these warnings.=