[Boost-bugs] [Boost C++ Libraries] #3546: Regex: bizarre behaviour in basic_regex::do_assign with MSVC 2008

Subject: [Boost-bugs] [Boost C++ Libraries] #3546: Regex: bizarre behaviour in basic_regex::do_assign with MSVC 2008
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-10-23 11:05:14


#3546: Regex: bizarre behaviour in basic_regex::do_assign with MSVC 2008
-------------------------------------------------+--------------------------
 Reporter: Keith MacDonald <keith@…> | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: regex
  Version: Boost 1.40.0 | Severity: Showstopper
 Keywords: |
-------------------------------------------------+--------------------------
 The attached program demonstrates the different behaviour, in release and
 debug modes, of basic_regex::do_assign when built with MSVC 2008 SP1.
 This can be observed in the following code, starting on line 696 of
 basic_regex.hpp:
 {{{
    if(!m_pimpl.get())
    {
       temp = shared_ptr<re_detail::basic_regex_implementation<charT,
 traits> >(new re_detail::basic_regex_implementation<charT, traits>());
    }
    else
    {
       temp = shared_ptr<re_detail::basic_regex_implementation<charT,
 traits> >(new re_detail::basic_regex_implementation<charT,
 traits>(m_pimpl->m_ptraits));
    }
 }}}

 In release mode, both assignments to temp seem to be executed!

 In order that the release code can be stepped through, it is necessary to
 build boost as follows:
 {{{
 bjam variant=release toolset=msvc link=static runtime-link=static
 threading=multi cxxflags=/Zi
 }}}
 The RegexBug project assumes that the boost libraries are installed in
 C:\Dev\boost_1_40_0\bin.v2\libs, so the "Additional library directories"
 property will have to be modified if they are installed elsewhere. Then,
 create the debug and release builds, and put a breakpoint on line 696 of
 basic_regex.hpp. Run the debug build first, and when the breakpoint is
 reached, add "this" and "temp" to the Watch Window. Then, step over each
 line to observe the correct behaviour. Now do the same thing with the
 release build and note that the address of temp changes twice while
 stepping through the if statement.

 Strangely, the subsequent call to regex_search succeeds in this sample
 code, but fails in my application. This is a complete showstopper for me,
 so I hope it can be easily fixed.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3546>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC