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. Advertisements

  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. Advertisements

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:
    1,195
    tom_usenet
    Oct 9, 2003
  2. Derek
    Replies:
    2
    Views:
    782
    Derek
    Dec 8, 2003
  3. ctick
    Replies:
    4
    Views:
    9,262
    Richard Herring
    Jun 22, 2004
  4. Ryan Mitchley
    Replies:
    6
    Views:
    11,622
    Maxim Yegorushkin
    Jun 26, 2004
  5. Toby Bradshaw
    Replies:
    6
    Views:
    2,091
    Kai-Uwe Bux
    Jun 2, 2006
  6. zl2k
    Replies:
    3
    Views:
    1,213
  7. Colin Caughie
    Replies:
    1
    Views:
    959
    Shooting
    Aug 29, 2006
  8. zl2k
    Replies:
    4
    Views:
    776
Loading...