All,
Since the introduction of Boost.Regex to support regular keyword
matching using regular expressions (opm-parser commit 9258651), I am no
longer able to use libstdc++'s "Debug Mode", viz.
https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html
to build OPM-related projects.
If I build the test at the bottom using (GCC 4.6.3, Boost 1.46.1, Ubuntu
12.04 LTS)
g++ -std=c++0x -Wall -Wextra -pedantic -UNDEBUG -O0 t.cpp \
-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1 \
-lboost_regex
I get
$ ./a.out
s = <hello>
Segmentation fault (core dumped)
whereas if I drop the '-D_GLIBCXX_DEBUG' flags (both of them) I get the
expected output
$ ./a.out
s = <hello>
s matches re (=.*)
s = <hello>
For the record: I get the same behaviour on CentOS 5.10 using GCC 4.7.0
and Boost 1.48.0. Anyone else noticing similar symptoms? Picking this
up in a debugger I notice that the call to boost::regex_match()
*appears* to change the input string ('s'), despite it being a
reference-to-const in that context.
The libstdc++ "Debug Mode" is very useful and has caught a number of
problems for me in the past so I'd like to keep the option of using it
for OPM. Therefore I'm asking if I'm doing something wrong or if anyone
knows if there's possibly an error in either of the libraries (my prime
suspect being Boost.Regex).
Regards,
Bård
-----------------8<---------------------------8<----------------------
#include <iostream>
#include <string>
#include <boost/regex.hpp>
int
main()
{
const std::string s("hello");
boost::regex re(".*");
std::cout << "s = <" << s << ">\n";
if (boost::regex_match(s, re)) {
std::cout << "s matches re (=" << re.str() << ")\n";
}
else {
std::cout << "s does not match";
}
std::cout << "s = <" << s << ">\n";
}
_______________________________________________
Opm mailing list
[email protected]
http://www.opm-project.org/mailman/listinfo/opm