public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array
       [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
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: law at redhat dot com @ 2020-04-18 17:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jeffrey A. Law <law at redhat dot com> ---
Isn't this ultimately a case of relying on the type information from that MEM
expression in a place where it's not valid?

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

* [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array
       [not found] <bug-92893-4@http.gcc.gnu.org/bugzilla/>
  2020-04-18 17:13 ` [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array 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
  3 siblings, 0 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-04-18 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #6)
> Isn't this ultimately a case of relying on the type information from that
> MEM expression in a place where it's not valid?

Yes, as I mentioned in comment #1, it's by design (which could stand to
improve).  I rewritten the whole function (compute_objsize) to deal with this
and a number of other problems due to the limitations of
compute_builtin_object_size (constant sizes, no ranges) that it relies on but
the changes are more intrusive than I feel comfortable for GCC 10.

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

* [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array
       [not found] <bug-92893-4@http.gcc.gnu.org/bugzilla/>
  2020-04-18 17:13 ` [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array 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
  3 siblings, 0 replies; 4+ messages in thread
From: law at redhat dot com @ 2020-04-18 18:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #8 from Jeffrey A. Law <law at redhat dot com> ---
Ultimately a duplicate of 87296.  Both are using the type of &MEM_REF which
leads to the invalid diagnotics.

*** This bug has been marked as a duplicate of bug 87296 ***

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

* [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array
       [not found] <bug-92893-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-04-18 18:49 ` law at redhat dot com
@ 2020-05-01 18:55 ` sbergman at redhat dot com
  3 siblings, 0 replies; 4+ messages in thread
From: sbergman at redhat dot com @ 2020-05-01 18:55 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2020-05-01 18:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-92893-4@http.gcc.gnu.org/bugzilla/>
2020-04-18 17:13 ` [Bug tree-optimization/92893] [10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array 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 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).