免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2126 | 回复: 1

Boost regex 在Linux上段错误 [复制链接]

论坛徽章:
0
发表于 2009-02-22 13:13 |显示全部楼层
代码如下:
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 }
环境是CentOS 5.2,编译,链接都没有问题,但是一运行,就出现了段错误,用GDB调试,发现:
Segmentation fault.
0x08048f68 in ~repeater_count (this=0xbfc5c378) at /usr/include/boost/regex/v4/perl_matcher.hpp:270
270 *stack = next;
在VS2005下工作的就很好,不知道为什么,呵呵。

[ 本帖最后由 zijian1984 于 2009-2-22 13:17 编辑 ]

论坛徽章:
0
发表于 2009-02-22 16:53 |显示全部楼层
9 boost::regex reg("test");
10
11 bool b = boost::regex_match("A test string", reg);
12

猜测可能是出在这个地方,之前我也出过段错误。
访问内存不合法所致。
你检查一下上边几个函数使用方法对了不。
我也是新手。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP