This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Bug in df_ref_unlink?
- From: "Christian Ehrhardt" <ehrhardt at mathematik dot uni-ulm dot de>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 21 Jan 2003 17:08:28 +0100
- Subject: Bug in df_ref_unlink?
Hi,
while reading through df.c I came across an oddity in df_ref_unlink.
* The comment above that function is obviously wrong
* The return value (only used by apparently unused function df_bb_def_use_swap)
is inconsistent, it should be a pointer to the link that was removed
but (unless I'm blind) it isn't in all cases).
Here's a (not yet regtestet) patch that illustates what should be
done before someone really starts to use the return value.
Index: df.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/df.c,v
retrieving revision 1.41
diff -u -r1.41 df.c
--- df.c 19 Dec 2002 05:18:04 -0000 1.41
+++ df.c 21 Jan 2003 15:57:49 -0000
@@ -656,7 +656,7 @@
}
-/* Add REF to chain head pointed to by PHEAD. */
+/* Remove a REF from chain head pointed to by PHEAD. */
static struct df_link *
df_ref_unlink (phead, ref)
struct df_link **phead;
@@ -689,8 +689,9 @@
if (link->next->ref == ref)
{
/* Unlink from list. */
+ struct df_link * tmp = link->next;
link->next = link->next->next;
- return link->next;
+ return tmp;
}
}
}
Comments? Do you want me to regtest this or am I really blind?
regards Christian
--
THAT'S ALL FOLKS!