LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2009, 10:54 PM   #1
zijian
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Rep: Reputation: 0
Boost regex Segmentation fault on Linux


Hi,I am trying to use the famous Boost regex library and write a c++ code like this:
1 #include <boost/regex.hpp>
2 #include <iostream>
3
4 using namespace std;
5
6
7 int main(void)
8 {
9 boost::regex reg("test");
10
11 bool b = boost::regex_match("A test string", reg);
12
13 if (b) {
14 cout<<"Success"<<endl;
15 }
16 else {
17 cout<<"Failed!\n";
18 }
19
20 return 0;
21 }
It's compiled and linked quite well, and when run it, got the segmentation fault. After I debug it, I found it was core dump at line 11
.
Segmentation fault.
0x08048f68 in ~repeater_count (this=0xbfc5c378) at /usr/include/boost/regex/v4/perl_matcher.hpp:270
270 *stack = next;

But it works very well in Visual studio 2005.
Anyone could give some help?
 
Old 02-21-2009, 11:19 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
It works on my machine, Slackware 12.2 with the boost package from testing/, gcc 4.2.4

What exact platform are you using?

Also, in the future, use [code] tags when posting, like
Code:
#include <boost/regex.hpp>
#include <iostream>

int main(int argc, char **argv)
{
   boost::regex reg("test");

   bool b = boost::regex_match("A test string", reg);

   if (b) {
      std::cout << "Success" << std::endl;
   }
   else {
      std::cout << "Failed!" << std::endl;
   }

   return 0;
}
 
Old 02-23-2009, 07:43 PM   #3
zijian
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you for your help. I use CentOS 5.2 final as the platform. It did works in Ubuntu.
 
Old 02-23-2009, 07:48 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
What version of boost is on the CentOS?
 
Old 02-24-2009, 12:05 AM   #5
zijian
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Original Poster
Rep: Reputation: 0
The last version, boost 1.38.0
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex.h problem in c++, segmentation fault vargadanis Programming 4 07-14-2008 05:36 PM
Problem with boost regex - can't compile easiest examples lodziarz Programming 3 02-28-2008 04:15 PM
Problem with Segmentation Fault in Linux akzare Programming 2 08-16-2006 11:42 PM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Segmentation fault on RedHat Linux 8.0 hemanth_13 Linux - General 2 07-28-2003 05:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration