- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Segmentation fault while c++ string concatenation....
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-14-2007 04:11 PM
тАО02-14-2007 04:11 PM
Segmentation fault while c++ string concatenation...
I build it on one HPUX box and test it on another, it gives me core dump whenever I do string operation or even cout gives me core dump.
I built and linked that using gcc 3.4.2
as
g++ -v -g -pthread -c test.cpp
g++ -v -o TestStaticString test.o -pthread -L /var/home/HPUXAGENT/lib -L/usr/local/lib -lpthread -lcrypt -lxnet -lnsl -lsec -lstdc++ -Xlinker +b -Xlinker ../lib:. -Xlinker +s -z
I have two HPUX machine;
Box1 : build machine
$ uname -a
HP-UX unknown B.11.11 U 9000/800 1925780423 unlimited-user license
Box2: Test machine
bash-2.04# uname -a
HP-UX kelp B.11.11 U 9000/785 2001873660 unlimited-user license
Attached file contains -
Sample Program
Sample program output
Core file analysis
program debugging with gdb
swlist on build machine
swlist on test machine
Building and linking
Build machine
Test machine
I have posted this on general forum and got much help , but I am posting this again here , beacause its more related to c++ language.
One last point , the same sample program works fine on a third HPUX box. The detail are given in the attached file
Any help regarding this is much appreciated.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2007 10:00 PM
тАО02-15-2007 10:00 PM
Re: Segmentation fault while c++ string concatenation...
string getfullname()
{ return (name + surname); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2007 10:08 PM
тАО02-15-2007 10:08 PM
Re: Segmentation fault while c++ string concatenation...
static1 s = new static1();
and call the methods as is
string fname = s.getfullname();
regards
Leonardo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-16-2007 02:35 PM - edited тАО10-16-2011 03:53 AM
тАО02-16-2007 02:35 PM - edited тАО10-16-2011 03:53 AM
Re: Segmentation fault while C++ string concatenation
>Leonardo: Try to modify method name as is: { return (name + surname); }
Adding () won't help. The problem is that static1::name isn't initialized.
>I suggest you to use this declaration:
>static1 s = new static1();
>and call the methods as is
>string fname = s.getfullname();
s needs to be a reference or object for ".".
Also, this doesn't solve the problem with "name".