CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2006
    Posts
    99

    Angry my copy constructor causes segmentation fault

    hello guys,

    i'm working with someone on a project. i always use windows, but he uses linux.

    so i need to move my code to linux before giving him.

    my code runs fine on my machine under linux, but he did some modification on the code and then we had a segmentation fault.

    the problematic line is a rather simple copy constructor that i implemented by myself, not generated by the compiler:

    Vector(const Vector &in):x(in.x),y(in.y),z(in.z)
    {
    }

    i don't know why this line can be a problem. please help.

    thank you so much

  2. #2
    Join Date
    Jan 2006
    Posts
    99

    Re: my copy constructor causes segmentation fault

    the error happens when i trying to do this line:

    Math::Vector pre=edgeAroundVertexIter->middlePoint;

    the error message also says:

    const CGAL::HalfedgeDS_in_place_list_halfedge<CGAL::I_Polyhedron_halfedge<My_edge<CGAL::HalfedgeDS_list_types<CGAL::Cartesian<float>, CGAL::I_Polyhedron_derived_items_3<My_items>, std::allocator<int> > > > > &) @0x0: <error reading variable>
    (gdb) p edgeAroundVertexIter->middlePoint

    this is weird, because i'm pretty sure middlePoint is a member and there was no compiling error at all.

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: my copy constructor causes segmentation fault

    Most likely something is corrupting middlePoint prior to that. Run valgrind on it, that might give you a clue.

  4. #4
    Join Date
    Jul 2008
    Location
    Be'er Sheva, Israel
    Posts
    69

    Re: my copy constructor causes segmentation fault

    Hi,
    Please provide the full class code, it is impossible to tell what went wrong just by looking at two lines...
    --How often do you look at a man's shoes?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured