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

Erik Eckstein eeckstein at apple.com
Mon Jul 28 03:44:33 PDT 2014


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 

On 11 Jul 2014, at 17:47, Erik Eckstein <eeckstein at apple.com> wrote:

> OK, I'll try to fix it.
> As I understood from the documentation the Prev of the first element should point to the sentinel.
> 
> On 10 Jul 2014, at 23:55, Reid Kleckner <rnk at google.com> wrote:
> 
>> I tripped over that also, it seems like a bug to me.
>> 
>> 
>> On Thu, Jul 10, 2014 at 5:59 AM, Erik Eckstein <eeckstein at apple.com> wrote:
>> 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
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140728/481c0484/attachment.html>


More information about the llvm-dev mailing list