public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "matt at godbolt dot org" <gcc-bugzilla@gcc.gnu.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	[thread overview]
Message-ID: <bug-106020-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-06-17 21:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 21:05 matt at godbolt dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106020-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).