public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mail+gnu at tzik dot jp" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101361] Bogus -Wstringop-overread warning with -O3 Date: Mon, 20 Mar 2023 13:08:21 +0000 [thread overview] Message-ID: <bug-101361-4-p6WQU9JhyF@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-101361-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101361 --- Comment #13 from Taiju Tsuiki <mail+gnu at tzik dot jp> --- I saw a similar inaccurate -Wstringop-overread warning with a smaller reproducer (attached). https://wandbox.org/permlink/EPjH0ZPoA4EWky0e Reproducing gcc was tip of trunk ( https://github.com/gcc-mirror/gcc/commits/33fb1625992ba8180b42988e714460bcab08ca0f ), and compile options and the error were: $ g++ -Werror -O3 -std=c++20 -c foo.cc In function ‘auto operator<=>(const V&, const V&)’, inlined from ‘Node* foo(Node*, const V&)’ at minify2/foo.cc:33:17: minify2/foo.cc:20:36: error: ‘int __builtin_memcmp(const void*, const void*, long unsigned int)’ specified bound [9223372036854775808, 18446744073709551615] exceeds maximum object size 9223372036854775807 (9) [-Werror=stringop-overread] 20 | const auto c = __builtin_memcmp(x.beg, y.beg, len) <=> 0; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ minify2/foo.cc:17:15: note: source object allocated here 17 | }(x.end - x.beg, y.end - y.beg); | ~~^~~ $ cat foo.cc #include <compare> struct Res { long min; std::strong_ordering cmp; }; struct V { const unsigned char* beg = nullptr; const unsigned char* end = nullptr; }; auto operator<=>(const V& x, const V& y) { const auto [len, lencmp] = [&](long len_x, long len_y) { auto c = len_x <=> len_y; return Res{c > 0 ? len_y : len_x, c}; }(x.end - x.beg, y.end - y.beg); if (len) { const auto c = __builtin_memcmp(x.beg, y.beg, len) <=> 0; if (c != 0) return c; } return lencmp; } struct Node { Node* next = nullptr; V v; }; Node* foo(Node* x, const V& k) { while (x && k < x->v) x = x->next; return x; }
prev parent reply other threads:[~2023-03-20 13:08 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-07 6:25 [Bug c++/101361] New: " boris at kolpackov dot net 2021-07-11 8:55 ` [Bug c++/101361] " Theodore.Papadopoulo at inria dot fr 2021-07-11 8:57 ` Theodore.Papadopoulo at inria dot fr 2021-07-12 22:56 ` [Bug libstdc++/101361] " msebor at gcc dot gnu.org 2021-07-13 11:08 ` redi at gcc dot gnu.org 2021-07-13 11:31 ` redi at gcc dot gnu.org 2021-07-13 12:17 ` redi at gcc dot gnu.org 2021-07-13 14:21 ` cvs-commit at gcc dot gnu.org 2021-07-13 14:41 ` msebor at gcc dot gnu.org 2021-07-14 15:00 ` cvs-commit at gcc dot gnu.org 2021-07-14 16:05 ` cvs-commit at gcc dot gnu.org 2021-07-14 16:07 ` [Bug c++/101361] " redi at gcc dot gnu.org 2023-03-20 12:58 ` mail+gnu at tzik dot jp 2023-03-20 13:08 ` mail+gnu at tzik dot jp [this message]
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-101361-4-p6WQU9JhyF@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: linkBe 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).