Bug 80051 - gcc/dwarf2out.c: PVS-Studio: V501
Summary: gcc/dwarf2out.c: PVS-Studio: V501
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 7.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: cppcheck
  Show dependency treegraph
 
Reported: 2017-03-15 15:14 UTC by Phillip Khandeliants
Modified: 2020-04-20 13:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-03-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Phillip Khandeliants 2017-03-15 15:14:29 UTC
We have found a bug using PVS-Studio tool. PVS-Studio is a static code analyzer for C, C++ and C#: https://www.viva64.com/en/pvs-studio/

Analyzer warning: V501 There are identical sub-expressions '!strcmp(a->v.val_vms_delta.lbl1, b->v.val_vms_delta.lbl1)' to the left and to the right of the '&&' operator. dwarf2out.c 1434

static bool dw_val_equal_p (dw_val_node *a, dw_val_node *b)
{
  ....
  switch (a->val_class)
  {
    ....
  case dw_val_class_vms_delta:
    return (   !strcmp (a->v.val_vms_delta.lbl1,
                        b->v.val_vms_delta.lbl1)
            && !strcmp (a->v.val_vms_delta.lbl1,     // <=
                        b->v.val_vms_delta.lbl1));   // <=
    ....
  }
  ....
}
Comment 1 Marek Polacek 2017-03-15 15:51:42 UTC
Confirmed.
Comment 2 Jakub Jelinek 2020-04-20 13:24:58 UTC
Fixed with r10-7770-ga64468a3034dd8e2d0794a5be84b8da544ffe2c3