strings命令没有预期的结果, 意味着异常!

来源:互联网 发布:js date转string 编辑:程序博客网 时间:2024/06/05 12:00

       最近遇到这样一个问题, strings命令没有预期的结果, 我真没想通为什么!  感觉很奇怪, 于是不敢发布版本。  

       这时候, 偶然发现了一个编译期的错误提示, 感觉到有问题, 一起来看看简单的示例:

#include<iostream>using namespace std;int main(){string s = "hello world";printf("%s", s);string name = "lucy";return 0;}

     用strings a.out | grep lucy 居然查不到这个串, 真是奇怪。 编译期间有错误:
test.cpp: In function ‘int main()’:
test.cpp:7: warning: cannot pass objects of non-POD type ‘struct std::string’ through ‘...’; call will abort at runtime

     看到了abort, 整个人就不好了, 会core dump啊, 回头看代码, 发现了错误。 改正后, 用strings命令就能看到lucy了。 

     本次提前发现了一个core dump!


1 0
原创粉丝点击