Bug 80051

Summary: gcc/dwarf2out.c: PVS-Studio: V501
Product: gcc Reporter: Phillip Khandeliants <khandeliants>
Component: otherAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: egallager, jakub
Priority: P3 Keywords: diagnostic
Version: 7.0.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2017-03-15 00:00:00
Bug Depends on:    
Bug Blocks: 89863    

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