This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/86516] New: Spurious warning __builtin_memset at O3 when protected by a conditional involving empty()


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

            Bug ID: 86516
           Summary: Spurious warning __builtin_memset at O3  when
                    protected by a conditional involving empty()
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: paulg at chiark dot greenend.org.uk
  Target Milestone: ---

This is spurious diagnostic regression in GCC 7 and beyond and is related to
two previous bugs.

The first one was was 82698 which was resolved as a duplicate of 88641. However
the workaround applied for 88641 is not complete and does not solve the
problem.

The issue is that at O3 if you do

std::vector<int> v;

if(c.size() > 0)
 c.resize(c.size() - 1);

then you no longer get a spurious builtin memset warning in 7.3 however if
instead you do

if(! c.empty())
 c.resize(c.size() -1);

it produces an erroneous warning. The fundamental problem is a dataflow
analysis issue which is somewhat difficult to fix.

In 88641 decorations were added to libstdc++ to avoid the warning however they
seem to have only been added to size() not empty() so the 2nd form of code
above still produces a spurious warning.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]