Thread: [Dev-C++] Glib::ustring::assign(...)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Jamiil A. <jal...@gm...> - 2007-08-17 02:35:10
|
WinXP GNU 3.4.2 I have this statement in=20 if(!title.empty()) { this->ustr->assign(title); // Segmentation Fault } Now, dbg reports that: #0 0x6650d384 std::string::assign(std::string const&) (??:??) #1 0x664d9c69 Glib::ustring::assign(Glib::ustring const&) = (/usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/bits/basic_string.h:427) #2 0x00401e83 jme::Combo::Combo(Glib::ustring const&) (??:??) #3 0x004027ea jme::NameFrame::Init() (??:??) #4 0x00402c54 jme::NameFrame::NameFrame() (??:??) #5 0x0040649c jme::Contacts::Contacts() (??:??) #6 0x00409f1d jme::Jaime::Init() (??:??) #7 0x004097e0 jme::Jaime::Jaime() (??:??) #8 0x0042068e main (??:??) Does anyone know what this error mean and/or what I can do to get rid of = the error? T.I.A. |
From: Adam J. <aj...@i-...> - 2007-08-17 18:13:15
|
If you are getting a Segmentation fault on this->ustr->assign(title); My guess would be that this-> or ustr-> pointer is not defined. Usually segmentation faults points to pointer allocation problems. I would check these pointers to make sure they are defined, by the time you try to use them. -Adam Jones From: dev...@li... [mailto:dev...@li...] On Behalf Of Jamiil Abduqadir Sent: Friday, August 17, 2007 1:40 AM To: Dev Cpp MailingLinst; gtk...@gn... Subject: [Dev-C++] Glib::ustring::assign(...) WinXP GNU 3.4.2 I have this statement in if(!title.empty()) { this->ustr->assign(title); // Segmentation Fault } Now, dbg reports that: #0 0x6650d384 std::string::assign(std::string const&) (??:??) #1 0x664d9c69 Glib::ustring::assign(Glib::ustring const&) (/usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/bits/basic_string.h:427) #2 0x00401e83 jme::Combo::Combo(Glib::ustring const&) (??:??) #3 0x004027ea jme::NameFrame::Init() (??:??) #4 0x00402c54 jme::NameFrame::NameFrame() (??:??) #5 0x0040649c jme::Contacts::Contacts() (??:??) #6 0x00409f1d jme::Jaime::Init() (??:??) #7 0x004097e0 jme::Jaime::Jaime() (??:??) #8 0x0042068e main (??:??) Does anyone know what this error mean and/or what I can do to get rid of the error? T.I.A. |
From: Jamiil A. <jal...@gm...> - 2007-08-17 23:41:52
|
std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown")); if(!title.empty()) { this->ustr->assign(title); // Segmentation Fault = <<=3D=3D=3D=3D=3D } Be my guest. ----- Original Message -----=20 From: Adam Jones=20 To: 'Dev Cpp MailingLinst'=20 Sent: Friday, August 17, 2007 11:13 AM Subject: Re: [Dev-C++] Glib::ustring::assign(...) If you are getting a Segmentation fault on this->ustr->assign(title); =20 My guess would be that this-> or ustr-> pointer is not defined. = Usually segmentation faults points to pointer allocation problems. I = would check these pointers to make sure they are defined, by the time = you try to use them. =20 -Adam Jones =20 From: dev...@li... = [mailto:dev...@li...] On Behalf Of Jamiil = Abduqadir Sent: Friday, August 17, 2007 1:40 AM To: Dev Cpp MailingLinst; gtk...@gn... Subject: [Dev-C++] Glib::ustring::assign(...) =20 WinXP GNU 3.4.2 I have this statement in=20 if(!title.empty()) { this->ustr->assign(title); // Segmentation Fault } Now, dbg reports that: #0 0x6650d384 std::string::assign(std::string const&) (??:??) #1 0x664d9c69 Glib::ustring::assign(Glib::ustring const&) = (/usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/bits/basic_string.h:427) #2 0x00401e83 jme::Combo::Combo(Glib::ustring const&) (??:??) #3 0x004027ea jme::NameFrame::Init() (??:??) #4 0x00402c54 jme::NameFrame::NameFrame() (??:??) #5 0x0040649c jme::Contacts::Contacts() (??:??) #6 0x00409f1d jme::Jaime::Init() (??:??) #7 0x004097e0 jme::Jaime::Jaime() (??:??) #8 0x0042068e main (??:??) =20 Does anyone know what this error mean and/or what I can do to get rid = of the error? =20 =20 T.I.A. -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a = browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ -------------------------------------------------------------------------= ----- _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Reid T. <rei...@at...> - 2007-08-18 00:31:04
|
Jamiil Abduqadir wrote: > std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown")); > if(!title.empty()) > { > this->ustr->assign(title); // Segmentation Fault <<===== > } > > Be my guest. what's the definition of ustr???? does this example work on your system? http://wwwasd.web.cern.ch/wwwasd/lhc++/RW/stdlibcr/aut_3512.htm // // auto_ptr.cpp // #include <iostream.h> #include <memory> // // A simple structure. // struct X { X (int i = 0) : m_i(i) { } int get() const { return m_i; } int m_i; }; int main () { // // b will hold a pointer to an X. // auto_ptr<X> b(new X(12345)); // // a will now be the owner of the underlying pointer. // auto_ptr<X> a = b; // // Output the value contained by the underlying pointer. // cout << a->get() << endl; // // The pointer will be deleted when a is destroyed on // leaving scope. // return 0; } Output : 12345 |
From: Jamiil A. <jal...@gm...> - 2007-08-18 14:28:28
|
Sorry, for being so lazy and not post a more elaborate question, I hope this would be a better way to ask this question. jme::Combo::Combo(const Glib::ustring& title){ Glib::ustring* ustr; std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown")); if(!title.empty()) { this->ustr->assign(title); } } Thanks in advance! ----- Original Message ----- From: "Reid Thompson" <rei...@at...> To: "Jamiil Abduqadir" <jal...@gm...> Cc: "'Dev Cpp MailingLinst'" <dev...@li...> Sent: Friday, August 17, 2007 5:33 PM Subject: Re: [Dev-C++] Glib::ustring::assign(...) > Jamiil Abduqadir wrote: >> std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown")); >> if(!title.empty()) >> { >> this->ustr->assign(title); // Segmentation Fault <<===== >> } >> Be my guest. > what's the definition of ustr???? > > > does this example work on your system? > > http://wwwasd.web.cern.ch/wwwasd/lhc++/RW/stdlibcr/aut_3512.htm > > // > // auto_ptr.cpp > // > #include <iostream.h> > #include <memory> > // > // A simple structure. > // > struct X > { > X (int i = 0) : m_i(i) { } > int get() const { return m_i; } > int m_i; > }; > int main () > { > // > // b will hold a pointer to an X. > // > auto_ptr<X> b(new X(12345)); > // > // a will now be the owner of the underlying pointer. > // > auto_ptr<X> a = b; > // > // Output the value contained by the underlying pointer. > // > cout << a->get() << endl; > // > // The pointer will be deleted when a is destroyed on > // leaving scope. > // > return 0; > } > Output : > 12345 |
From: matheus r. <mfr...@gm...> - 2007-08-18 15:49:55
|
> jme::Combo::Combo(const Glib::ustring& title){ > Glib::ustring* ustr; > std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown")); > if(!title.empty()) { > this->ustr->assign(title); > } > } > Thanks in advance! My guess is that ustr is both a local variable and a member variable with the same name. In the example above, you assigned the new glib string to the local variable but used assign on the member below, which was probably not initialized. If both are auto_ptr, I guess what you wanted to do is: ustr.reset(new Glib::ustring("Unknown")); instead of std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown")); |