This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] annotate vector::_M_default_append fo better codegen (PR 83229)
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Dec 2017 15:07:17 +0000
- Subject: Re: [PATCH] annotate vector::_M_default_append fo better codegen (PR 83229)
- Authentication-results: sourceware.org; auth=none
- References: <e341f282-f072-8543-d143-44248dad3cb6@gmail.com>
On 05/12/17 20:44 -0700, Martin Sebor wrote:
Bug 83239 - False positive from -Wstringop-overflow on simple
std::vector code, besides pointing out the warning, suggests
a missed optimization opportunity. This is the second report
involving for vector (the last one was pr79095) with the same
symptoms and a similar root cause. Since the information GCC
keeps about pointers is limited, it's difficult to determine
that their relationship is p <= q <= r. This is exacerbated
by the fact that GCC doesn't know that the difference between
any two pointers into the same object cannot be greater than
PTRDIFF_MAX (bug 79119).
To help GCC generate better code and avoid the false positive,
the attached patch adds simple instrumentation to
vector::_M_default_append() asserting the important pointer
relationships.
The vector annotation is OK for trunk, thanks.