https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124578
Bug ID: 124578
Summary: tree-ssa-sccvn.c: 938: Possible cut'n'paste error ?
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
I get emails from Coverity about possible bugs in gcc trunk.
One such is this:
*** CID 1689871: Incorrect expression (COPY_PASTE_ERROR)
/root/gcc-coverity/gcc/tree-ssa-sccvn.cc: 936 in
vn_reference_eq(const vn_reference_s *, const vn_reference_s *, bool)()
930 || ! TYPE_SIZE (vro2->type)
931 || ! operand_equal_p (TYPE_SIZE (vro1->type),
932 TYPE_SIZE (vro2->type))))
933 || (get_deref_alias_set (vro1->opcode == MEM_REF
934 ? TREE_TYPE (vro1->op0)
935 : TREE_TYPE (vro1->op2))
>>> CID 1689871: Incorrect expression (COPY_PASTE_ERROR)
>>> "vro1" in "(vro1->opcode == MEM_REF) ? contains_struct_check(vro2->op0,
>>> TS_TYPED, "../../gcc/tree-ssa-sccvn.cc", 937, <anonymous>)->typed.type :
>>> contains_struct_check(vro2->op2, TS_TYPED, "../../gcc/tree-ssa-sccvn.cc",
>>> 938, <anonymous>)->typed.type" looks like a copy-paste error.
Source code is
if (lexical
&& (vro1->opcode == MEM_REF
|| vro1->opcode == TARGET_MEM_REF)
&& (TYPE_ALIGN (vro1->type) != TYPE_ALIGN (vro2->type)
|| (TYPE_SIZE (vro1->type) != TYPE_SIZE (vro2->type)
&& (! TYPE_SIZE (vro1->type)
|| ! TYPE_SIZE (vro2->type)
|| ! operand_equal_p (TYPE_SIZE (vro1->type),
TYPE_SIZE (vro2->type))))
|| (get_deref_alias_set (vro1->opcode == MEM_REF
? TREE_TYPE (vro1->op0)
: TREE_TYPE (vro1->op2))
!= get_deref_alias_set (vro1->opcode == MEM_REF
? TREE_TYPE (vro2->op0)
: TREE_TYPE (vro2->op2)))))
I think what it is complaining about is that the line 3
from the end should be
!= get_deref_alias_set (vro2->opcode == MEM_REF
This if conditional is 15 lines long and could IMHO benefit
from some simplification.
git blame thinks Richard B was the last to touch this code.