[Dune] [#493] test failure: dune-common/common/test/sllisttest
Dune
dune at dune-project.org
Fri Oct 2 18:07:22 CEST 2009
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#493 - test failure: dune-common/common/test/sllisttest
User who did this - Oliver Sander (sander)
----------
Here is a reduced testcase. Still long though, but I won't continue reducing tonight.
This really is a PoolAllocator issue. I'd close it as a duplicate of 491 if it wasn't for the different set of compiler flags used there.
#include<dune/common/poolallocator.hh>
#include<iostream>
#include <cassert>
typedef Dune::PoolAllocator<int,8*1024-16> IntAllocator;
struct Element
{
Element* next_;
int item_;
Element() : next_(0), item_() {}
};
template <class T>
struct SLList {
SLList()
: tail_(&beforeHead_)
{
beforeHead_.next_=0;
}
Element beforeHead_;
Element* tail_;
};
int main()
{
typedef IntAllocator TheAllocator;
//typedef std::allocator<int> TheAllocator;
SLList<int> alist;
/** @brief Pseudo element before the first entry. */
TheAllocator::rebind<Element>::other allocator_;
//alist.push_back(1);
int item = 1;
alist.tail_->next_ = allocator_.allocate(1, 0);
alist.tail_ = alist.tail_->next_;
::new (static_cast<void*>(&(alist.tail_->item_))) int(item);
alist.tail_->next_=0;
assert(alist.tail_->next_==0);
//if(*(alist.begin())!=1) {
assert(alist.beforeHead_.next_->item_ == 1);
//alist.push_front(3);
item = 3;
if(alist.tail_ == &alist.beforeHead_){
// list was empty
alist.beforeHead_.next_ = alist.tail_ = allocator_.allocate(1, 0);
::new(static_cast<void*>(&alist.beforeHead_.next_->item_)) int(item);
alist.beforeHead_.next_->next_=0;
}else{
Element* added = allocator_.allocate(1, 0);
::new(static_cast<void*>(&added->item_)) int(item);
added->next_=alist.beforeHead_.next_;
alist.beforeHead_.next_=added;
}
assert(alist.tail_->next_==0);
//if(*(alist.begin())!=3){
assert(alist.beforeHead_.next_->item_ == 3);
//alist.pop_front();
assert(alist.beforeHead_.next_);
Element* next = alist.beforeHead_.next_;
// deleting last element changes tail!
if(next == alist.tail_)
alist.tail_ = &alist.beforeHead_;
alist.beforeHead_.next_ = next->next_;
//next->item_.~T();
next->next_ = 0;
allocator_.deallocate(next, 1);
//if(*(alist.begin())!=1){
if (alist.beforeHead_.next_->item_ != 1) {
std::cerr<<"Entry should be 1, but is "<< alist.beforeHead_.next_->item_ <<"! Push back failed! "<<__FILE__<<":"<<__LINE__<<std::endl;
assert(false);
}
return 0;
}
----------
More information can be found at the following URL:
http://www.dune-project.org/flyspray/index.php?do=details&task_id=493#comment1163
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
More information about the Dune
mailing list