
I'm seeing an inexplicable failure in xpressive on HP Tru64. My highly scientific approach of randomly changing stuff and hoping for the best hasn't panned out. Is there anybody with this compiler who would like to help out tracking down this bug: <http://tinyurl.com/3e3low>? Just try compiling the following program: #include <iostream> #include <boost/xpressive/xpressive.hpp> using namespace boost; using namespace xpressive; int main() { sregex rex = +_w; std::string str("foo bar baz"); std::string fmt("\\u$&"); str = regex_replace(str, rex, fmt, regex_constants::format_perl); std::cout << "Expected : Foo Bar Baz" << std::endl; std::cout << "Actual : " << str << std::endl; return 0; } Based on the test failure, I'm guessing the actual output will be: Expected : Foo Bar Baz Actual : FOO BAR BAZ If that's the case, I'll be asking you to fire up a debugger. I can tell you exactly where to look, but only you can tell me what you'll find! -- Eric Niebler Boost Consulting www.boost-consulting.com

Eric Niebler schrieb:
I'm seeing an inexplicable failure in xpressive on HP Tru64. My highly scientific approach of randomly changing stuff and hoping for the best hasn't panned out. Is there anybody with this compiler who would like to help out tracking down this bug: <http://tinyurl.com/3e3low>?
[...] Will do on Monday and report my findings. Markus

Eric Niebler wrote: [...]
Based on the test failure, I'm guessing the actual output will be:
Expected : Foo Bar Baz Actual : FOO BAR BAZ
Your expectations were right.
If that's the case, I'll be asking you to fire up a debugger. I can tell you exactly where to look, but only you can tell me what you'll find!
I did so and I think I've found the source of the problem. The Tru64/CXX std library implements copy as: while (first != last) *result++ = *first++; XPressive uses copy in format_backref_ like this: else if(BOOST_XPR_CHAR_(char_type, '&') == *cur) // whole match { ++cur; out = std::copy( this->sub_matches_[ 0 ].first, this->sub_matches_[ 0 ].second, out); } This results in calls of the post increment operator of case_converting_iterator, which returns a copy of the iterator object. The assignment operator then modifies this copy and not the original iterator, nullifying the changes done to the iterator object in the assignment operator. The test executes OK when I replace the implementation of copy with the following code: while (first != last) { *result = *first; ++first; ++result; } HTH, Markus

Markus Schöpflin wrote:
The Tru64/CXX std library implements copy as:
while (first != last) *result++ = *first++;
XPressive uses copy in format_backref_ like this:
else if(BOOST_XPR_CHAR_(char_type, '&') == *cur) // whole match { ++cur; out = std::copy( this->sub_matches_[ 0 ].first, this->sub_matches_[ 0 ].second, out); }
This results in calls of the post increment operator of case_converting_iterator, which returns a copy of the iterator object. The assignment operator then modifies this copy and not the original iterator, nullifying the changes done to the iterator object in the assignment operator.
The test executes OK when I replace the implementation of copy with the following code:
while (first != last) { *result = *first; ++first; ++result; }
Ah, ha! A million thanks Markus! I'll find a work around. And credit you for your help, of course. -- Eric Niebler Boost Consulting www.boost-consulting.com

AMDG Eric Niebler <eric <at> boost-consulting.com> writes:
The test executes OK when I replace the implementation of copy with the following code:
while (first != last) { *result = *first; ++first; ++result; }
Ah, ha! A million thanks Markus! I'll find a work around. And credit you for your help, of course.
Wouldn't it be better to move this->next_ = None; from operator= to operator++? Then std::copy will work correctly. In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
Eric Niebler <eric <at> boost-consulting.com> writes:
The test executes OK when I replace the implementation of copy with the following code:
while (first != last) { *result = *first; ++first; ++result; } Ah, ha! A million thanks Markus! I'll find a work around. And credit you for your help, of course.
Wouldn't it be better to move
this->next_ = None;
from operator= to operator++?
Then std::copy will work correctly.
Great suggestion. Thanks Steven. -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (4)
-
Eric Niebler
-
Markus Schöpflin
-
Markus Schöpflin
-
Steven Watanabe