bug in ilist_node::getPrevNode() ?

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.


I tripped over that also, it seems like a bug to me.

OK, I’ll try to fix it.
As I understood from the documentation the Prev of the first element should point to the sentinel.

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?