boost::shared_ptr inside stl::list

J

James Mastro

This one has been driving me nuts all day. In a function I have the
following:

std::list< boost::shared_ptr<MyObject> > * objectList;


When debugging my code, the debugger (gdb) dies upon entering the
function with this in it. It says "The Debugger has exited due to signal
11 (SIGSEGV).The Debugger has exited due to signal 11 (SIGSEGV)." My dev
tools felt the need to say it twice for some reason. I pulled this out
and put it in a new project all by itself with the same result.

If I make it not be a pointer, like this:

std::list< boost::shared_ptr<MyObject> > objectList;

then there's no problem.

Oddly, both versions of the code work fine when run normally (not being
debugged.)

I don't see what's wrong with the first version. Is it OK to put boost
shared ptrs in a std::list? Is there something else I'm missing?

Or is my dev environment just having problems?


-jim
 
C

Cy Edmunds

James Mastro said:
This one has been driving me nuts all day. In a function I have the
following:

std::list< boost::shared_ptr<MyObject> > * objectList;


When debugging my code, the debugger (gdb) dies upon entering the
function with this in it. It says "The Debugger has exited due to signal
11 (SIGSEGV).The Debugger has exited due to signal 11 (SIGSEGV)." My dev
tools felt the need to say it twice for some reason. I pulled this out
and put it in a new project all by itself with the same result.

If I make it not be a pointer, like this:

std::list< boost::shared_ptr<MyObject> > objectList;

then there's no problem.

Oddly, both versions of the code work fine when run normally (not being
debugged.)

I don't see what's wrong with the first version. Is it OK to put boost
shared ptrs in a std::list? Is there something else I'm missing?

Or is my dev environment just having problems?


-jim

I don't understand why the pointer version works without the debugger so I
can't help you there. But boost::shared_ptr works fine with std::list in my
applications.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top