[LLVMdev] bug in ilist_node::getPrevNode() ?

15 views
Skip to first unread message

Erik Eckstein

unread,
Jul 10, 2014, 9:06:05 AM7/10/14
to llv...@cs.uiuc.edu
Hi all,

I stumbled over a problem in ilist_node::getPrevNode(). It crashes when invoked for the first element in a list.
It's because the Prev pointer of a first list element does not point to the sentinel but is just null.

First question: Is this really a bug or am I doing something wrong?
Second question: If it is a bug, what should be the correct behaviour? Either change insert() to let Prev of the first element really point to the sentinel or just change getPrevNode()?

I don't really need getPrevNode() because I can also use iterators but if this is really a bug, I think it should be fixed.

Thanks,
Erik


_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Reid Kleckner

unread,
Jul 10, 2014, 5:58:34 PM7/10/14
to Erik Eckstein, LLVM Developers Mailing List
I tripped over that also, it seems like a bug to me.

Erik Eckstein

unread,
Jul 11, 2014, 11:55:11 AM7/11/14
to Reid Kleckner, LLVM Developers Mailing List
OK, I'll try to fix it.
As I understood from the documentation the Prev of the first element should point to the sentinel.

Erik Eckstein

unread,
Jul 28, 2014, 6:53:01 AM7/28/14
to LLVM Developers Mailing List
I looked at this and found two problems:

1) Many list instantiations do not initialise their sentinel, like it should be done in ilist_sentinel_traits:: ensureHead()
This can be fixed easily. Even in ilist.h, so that not all usages of ilist must be modified.

2) Some list instantiations use only a ilist_half_node instead of a ilist_node for the sentinel.
This is OK for all list operations, except getPrevNode() and getNextNode().
I assume that ilist_half_node is used to save space (the next-pointer).

Now the question is: should all sentinels be changed to ilist_node. This will fix getPrevNode() and getNextNode()?
Or should it stay like it is and specify that getPrevNode()/getNextNode()  cannot be used on lists which have a ilist_half_node sentinel?

Thanks,
Erik 
Reply all
Reply to author
Forward
0 new messages