Error in std::list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I tried the following
struct STRUCTTWO
[...
}

struct STRUCTONE
[...
std::list<STRUCTTWO> test
}

std::list<STRUCTONE> mylist

Now, when I try to add an element via std::list::insert, the whole stuff crashes: Access Violation in const_iterator begin() (this is in <list>). The MFC- equivalent CList behaves just the same!

Can anyone help me out of this

Thanks a lo
Peter
 
Peter said:
Hi,

I tried the following:
struct STRUCTTWO {
[...]
};

struct STRUCTONE {
[...]
std::list<STRUCTTWO> test;
};

std::list<STRUCTONE> mylist;

Now, when I try to add an element via std::list::insert, the whole stuff crashes: Access Violation in const_iterator begin()
(this is in <list>). The MFC- equivalent CList behaves just the same!!

Can anyone help me out of this?

The error must be in the code you omitted.
Create a small repro case that produces the
error. It is likely that you will find out about the
error while doing so. Otherwise post the repro.
SOmeone here might find what's wrong.
Thanks a lot
Peter


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
Peter said:
[...]
Now, when I try to add an element via std::list::insert, the whole stuff crashes: Access Violation in const_iterator begin()
(this is in <list>). The MFC- equivalent CList behaves just the same!!

Show the call to 'std::list said:
Can anyone help me out of this?

Thanks a lot
Peter

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
Peter said:
mylist.insert(mylist.end(),teststruct); //teststruct is a valid STRUCTONE


Well, this

#include <list>

struct STRUCTTWO {
int i;
//DWORD dw;
};

struct STRUCTONE {
int i;
//DWORD dw;
std::list<STRUCTTWO> test;
};

std::list<STRUCTONE> mylist;

int main()
{
STRUCTONE one;
one.i = 0;
mylist.insert( mylist.end(), one );
return 0;
}

works (i.e. doesn't crash) for me, so I'm
still sure it's something in your code that
you didn't show.

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
Peter said:
Have you tried to fill the STRUCTTWO linked list with some stuff?

No, and I keep saying it would be your
task to create a repro. If you see an
error with some code, reduce the code
to some lines we all can copy'n'paste
into our editors and post this.
I did this twice yesterday and in the
end I didn't have to post it because
I understood the problem when I was
doing this.


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
Back
Top