boost::shared_ptr inside stl::list

Discussion in 'C++' started by James Mastro, Nov 13, 2003.

  1. James Mastro

    James Mastro Guest

    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
     
    James Mastro, Nov 13, 2003
    #1
    1. Advertising

  2. James Mastro

    Cy Edmunds Guest

    "James Mastro" <> wrote in message
    news:...
    > 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.

    --
    Cy
    http://home.rochester.rr.com/cyhome/
     
    Cy Edmunds, Nov 13, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Philippe Guglielmetti
    Replies:
    4
    Views:
    909
    tom_usenet
    Oct 9, 2003
  2. Toby Bradshaw
    Replies:
    6
    Views:
    1,782
    Kai-Uwe Bux
    Jun 2, 2006
  3. zl2k
    Replies:
    3
    Views:
    1,035
  4. Colin Caughie
    Replies:
    1
    Views:
    738
    Shooting
    Aug 29, 2006
  5. zl2k
    Replies:
    4
    Views:
    640
Loading...

Share This Page