|
From: Hossein H. <ult...@em...> - 2003-07-15 10:57:15
|
Shane, > > When it breaks out into GDB in the crash, > > it leaves me at > > a "map::find" statement, which, when I step into it, I find > > that the key (an > > std::string) is valid, but the data portion, a pointer to an > > allocated User, > > is somehow fubar'd, because if I try to print (no different > > than getting the > > value of a variable in VC++ debugger) the pointer, GDB itself > > will indicate > > that the program crashed while attempting to execute > > something by GDB. This > > means that 1) the code crashes and drops me into the > > debugger, and 2) it is > > in fact crashing because of the variable value, as executing > > the single > > operation of printing the value causes an internal crash that > > GDB recovers > > from, but ends execution of the program. > > > This is happening because you use the library in an improper C style way. > Had the map contained objects instead of pointers you would find no record > when you used the find() and would get User(0) when accessed the key using > operator[]. Better use C++ as C++ and not as C. Yep! I agree. Maybe not a bad idea to follow this. > > The problem I am seeing, I have never seen in all my time > > programming, and I > > have a good 8 years background with C. Further issues with > > this, may result > > in me reverting UserList to a true linked list > > implementation, instead of > > STL, which could be the culprit even though I don't want to > > blame it. > > > !!! The problem is your programming approach, not the standard library! I do not want to offend you, but perhaps he is right. You have tested everything, right? Why don't you test this one? (Forgive me if you have done it before.) > > Even > > reverting temporarily to a C linked list may help me in > > travelling the list > > in the debugger to find out where the problem is (like if > > it's the last or > > first element, etc)... Short of testing my new changes, this > > will be the > > next step, to revert to a very slow and simple linked list > > until I can track > > down the problem. At least I have some direction, I > > appreciate the help > > everyone has offered. > > > The standard library provides a double linked list implementation, > std::list. But your problem is that you code in C with classes, not C++! Probabely yeah! Regards, --Hossein -- __________________________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup CareerBuilder.com has over 400,000 jobs. Be smarter about your job search http://corp.mail.com/careers |