Ticket #12300: boostrebug.cpp

File boostrebug.cpp, 522 bytes (added by Pascal Séguy <pascal.seguy@…>, 6 years ago)
Line 
1#include <cassert>
2#include <cstring> // strlen
3#include <string>
4#include <boost/regex.hpp>
5
6
7int main()
8{
9static boost::regex re("^\\s*(\\S+)"); // My RE
10boost::smatch match;
11std::string comm = "abcd"; // the input string
12
13 if(boost::regex_search(comm, match, re)) {
14 comm = match.suffix(); // eat the matched word
15 std::string word(match.str(1)); // get the matched word
16 assert(strlen(word.c_str()) > 0); // ASSERTION FAILS!!!
17 // "word" should be "abcd", gdb output:
18 // (gdb) p word
19 // $1 = "\000bcd"
20 }
21}
22