public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sbergman at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array Date: Fri, 01 May 2020 18:55:29 +0000 [thread overview] Message-ID: <bug-92893-4-yJXbKoc27h@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-92893-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893 --- Comment #9 from Stephan Bergmann <sbergman at redhat dot com> --- (In reply to Martin Sebor from comment #2) > Defining Str like so works for the test case: > > struct Str { > template<typename T1, typename T2> Str(Cat<T1, T2> c) > { > struct Flex { char c, a[]; } *p = (Flex*)get(); > c.add(p->a); > } > }; So I had created <https://gerrit.libreoffice.org/c/core/+/85161> "Silence bogus -Wstringop-overflow with GCC trunk towards GCC 10" back in last December, and it sufficed to suppress all those warnings when compiling LibreOffice with then-trunk GCC, with optimizations enabled. However, meanwhile GCC has changed again so that at least one place in the LibreOffice code now produces two -Werror=stringop-overflow= in one such struct Hack { char c; char a[]; }; workaround. (While in general the workarounds appear to still be effective in suppressing other such warnings.) Bisecting, I found that first > commit ef29b12cfbb4979a89b3cbadbf485a77c8fd8fce > Author: Martin Sebor <msebor@redhat.com> > Date: Sat Dec 14 00:52:46 2019 +0000 > > PR middle-end/91582 - missing heap overflow detection for strcpy caused a new "writing 1 byte into a region of size 0" at > In file included from /home/user/libreoffice/include/rtl/string.hxx:41, > from /home/user/libreoffice/include/rtl/ustring.hxx:37, > from /home/user/libreoffice/include/unotest/filters-test.hxx:14, > from /home/user/libreoffice/unotest/source/cpp/filters-test.cxx:14: > In member function ‘char* rtl::OStringConcat<T1, T2>::addData(char*) const [with T1 = rtl::OStringLiteral; T2 = const char [2]]’, > inlined from ‘char* rtl::OStringConcat<T1, T2>::addData(char*) const [with T1 = rtl::OStringConcat<rtl::OStringLiteral, const char [2]>; T2 = rtl::OString]’ at /home/user/libreoffice/include/rtl/stringconcat.hxx:256:114, > inlined from ‘rtl::OString::OString(rtl::OStringConcat<T1, T2>&&) [with T1 = rtl::OStringConcat<rtl::OStringLiteral, const char [2]>; T2 = rtl::OString]’ at /home/user/libreoffice/include/rtl/string.hxx:281:34, > inlined from ‘void test::FiltersTest::recursiveScan(test::filterStatus, const rtl::OUString&, const rtl::OUString&, const rtl::OUString&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool)’ at /home/user/libreoffice/unotest/source/cpp/filters-test.cxx:111:67: > /home/user/libreoffice/include/rtl/stringconcat.hxx:77:11: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] > 77 | memcpy( buffer, data, length ); > | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ > In file included from /home/user/libreoffice/include/rtl/ustring.hxx:37, > from /home/user/libreoffice/include/unotest/filters-test.hxx:14, > from /home/user/libreoffice/unotest/source/cpp/filters-test.cxx:14: > /home/user/libreoffice/include/rtl/string.hxx: In member function ‘void test::FiltersTest::recursiveScan(test::filterStatus, const rtl::OUString&, const rtl::OUString&, const rtl::OUString&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool)’: > /home/user/libreoffice/include/rtl/string.hxx:280:32: note: at offset 0 to object ‘rtl::OString::OString(rtl::OStringConcat<T1, T2>&&) [with T1 = rtl::OStringConcat<rtl::OStringLiteral, const char [2]>; T2 = rtl::OString]::Hack::c’ with size 1 declared here > 280 | struct Hack { char c; char a[]; }; > | ^ and later > commit a9a437ffc4269650e34af92c4fb095b7ed98f94a > Author: Jakub Jelinek <jakub@redhat.com> > Date: Tue Mar 17 13:36:41 2020 +0100 > > tree-ssa-strlen: Fix up count_nonzero_bytes* [PR94015] started to even cause an additional "writing 4 bytes into a region of size 1" > In file included from /home/user/libreoffice/include/rtl/string.hxx:41, > from /home/user/libreoffice/include/rtl/ustring.hxx:37, > from /home/user/libreoffice/include/unotest/filters-test.hxx:14, > from /home/user/libreoffice/unotest/source/cpp/filters-test.cxx:14: > In function ‘char* rtl::addDataHelper(char*, const char*, std::size_t)’, > inlined from ‘static char* rtl::ToStringHelper<rtl::OStringLiteral>::addData(char*, const rtl::OStringLiteral&)’ at /home/user/libreoffice/include/rtl/string.hxx:1907:91, > inlined from ‘char* rtl::OStringConcat<T1, T2>::addData(char*) const [with T1 = rtl::OStringLiteral; T2 = const char [2]]’ at /home/user/libreoffice/include/rtl/stringconcat.hxx:222:103, > inlined from ‘char* rtl::OStringConcat<T1, T2>::addData(char*) const [with T1 = rtl::OStringConcat<rtl::OStringLiteral, const char [2]>; T2 = rtl::OString]’ at /home/user/libreoffice/include/rtl/stringconcat.hxx:256:114, > inlined from ‘rtl::OString::OString(rtl::OStringConcat<T1, T2>&&) [with T1 = rtl::OStringConcat<rtl::OStringLiteral, const char [2]>; T2 = rtl::OString]’ at /home/user/libreoffice/include/rtl/string.hxx:281:34, > inlined from ‘void test::FiltersTest::recursiveScan(test::filterStatus, const rtl::OUString&, const rtl::OUString&, const rtl::OUString&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool)’ at /home/user/libreoffice/unotest/source/cpp/filters-test.cxx:111:67: > /home/user/libreoffice/include/rtl/stringconcat.hxx:77:11: error: writing 4 bytes into a region of size 1 [-Werror=stringop-overflow=] > 77 | memcpy( buffer, data, length ); > | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ > In file included from /home/user/libreoffice/include/rtl/ustring.hxx:37, > from /home/user/libreoffice/include/unotest/filters-test.hxx:14, > from /home/user/libreoffice/unotest/source/cpp/filters-test.cxx:14: > /home/user/libreoffice/include/rtl/string.hxx: In member function ‘void test::FiltersTest::recursiveScan(test::filterStatus, const rtl::OUString&, const rtl::OUString&, const rtl::OUString&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool)’: > /home/user/libreoffice/include/rtl/string.hxx:280:32: note: at offset 0 to object ‘rtl::OString::OString(rtl::OStringConcat<T1, T2>&&) [with T1 = rtl::OStringConcat<rtl::OStringLiteral, const char [2]>; T2 = rtl::OString]::Hack::c’ with size 1 declared here > 280 | struct Hack { char c; char a[]; }; > | ^ preceding the other warning.
prev parent reply other threads:[~2020-05-01 18:55 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-92893-4@http.gcc.gnu.org/bugzilla/> 2020-04-18 17:13 ` law at redhat dot com 2020-04-18 17:52 ` msebor at gcc dot gnu.org 2020-04-18 18:49 ` law at redhat dot com 2020-05-01 18:55 ` sbergman at redhat dot com [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-92893-4-yJXbKoc27h@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).