正则表达式代码无故停止工作

时间:2018-06-26 04:41:45

标签: c++ netbeans

这是我要构建和编译的代码。我不确定自己做了什么,但是这段代码以前曾经工作过(几周前)。

#include <regex>

using namespace std;

int main(int argc, char** argv) {
    regex txt_regex("[a-z]+\\.txt");
    return 0;
}

这是来自netbeans的错误日志

cd '/home/dev/Desktop/test'
/usr/bin/make -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/dev/Desktop/test'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/test
make[2]: Entering directory '/home/dev/Desktop/test'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++    -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
In file included from /usr/include/c++/5/regex:60:0,
                 from main.cpp:1:
/usr/include/c++/5/bits/regex_compiler.h: In member function ‘bool std::__detail::_AnyMatcher<_TraitsT, false, __icase, __collate>::operator()(std::__detail::_AnyMatcher<_TraitsT, false, __icase, __collate>::_CharT) const [with _TraitsT = std::__cxx11::regex_traits<char>; bool __icase = true; bool __collate = false; std::__detail::_AnyMatcher<_TraitsT, false, __icase, __collate>::_CharT = char]’:
/usr/include/c++/5/bits/regex_compiler.h:292:7: internal compiler error: Segmentation fault
       operator()(_CharT __ch) const
       ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/GNU-Linux/main.o' failed
make[2]: *** [build/Debug/GNU-Linux/main.o] Error 1
make[2]: Leaving directory '/home/dev/Desktop/test'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/dev/Desktop/test'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

发生了什么事?

1 个答案:

答案 0 :(得分:0)

更新系统后,代码将再次起作用:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade