Boost C++ Libraries: Ticket #4685: boost::interprocess::winapi::get_last_bootup_time( std::wstring&) https://svn.boost.org/trac10/ticket/4685 <p> boost::interprocess::winapi::get_last_bootup_time( std::wstring&amp; strValue ) </p> <p> This line is wrong and is crashing most of the win32 regression tests (both release and trunk): </p> <pre class="wiki">strValue.erase(strValue.find(L'+')); </pre><p> strValue doesn't have '+', so .find() returns std::wstring::npos, but that causes std::wstring::erase() to crash. npos isn't a valid parameter to erase() and will cause an out_of_range exception to be thrown. <a class="ext-link" href="http://stdcxx.apache.org/doc/stdlibref/basic-string.html#idx349"><span class="icon">​</span>http://stdcxx.apache.org/doc/stdlibref/basic-string.html#idx349</a> </p> <p> I think this is causing many regression test failures both the release and trunk branches for win32. </p> <p> The fix would be to split it out: </p> <pre class="wiki">std::wstring::size_type plusPos = strValue.find(L'+'); if (plusPos != std::wstring::npos) strValue.erase(plusPos); </pre><p> I can't speak to why you're looking for a '+' and the significance of not finding it. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4685 Trac 1.4.3 Ion Gaztañaga Sun, 26 Sep 2010 05:50:12 GMT <link>https://svn.boost.org/trac10/ticket/4685#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4685#comment:1</guid> <description> <p> ¿Which failures? I see in trunk that some msvc tests are fine: </p> <p> <a href="http://www.boost.org/development/tests/release/developer/interprocess.html">http://www.boost.org/development/tests/release/developer/interprocess.html</a> </p> <p> In my machine the string returned from windows WMI is: </p> <p> 20100918163015.375199+120 </p> <p> Maybe depending on the time zone, the offset part (+120 or whatever) is not present. Could you please print string contents to see what is windows WMI returning? </p> <p> I will applying the patch but I wanted to be sure that it fixes the problem. </p> </description> <category>Ticket</category> </item> <item> <author>Jim Bell <jim@…></author> <pubDate>Sun, 26 Sep 2010 20:52:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4685#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4685#comment:2</guid> <description> <p> My machine returns: </p> <p> 20100923072129.484625-300 </p> <p> 60% of the interprocess release tests fail under msvc-8.0 and some other win32 platforms. I think this one bug is causing many of them. </p> <p> The above npos-check made my test code run. Without it, it crashed. </p> </description> <category>Ticket</category> </item> <item> <author>Jim Bell <jim@…></author> <pubDate>Sun, 26 Sep 2010 21:44:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4685#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4685#comment:3</guid> <description> <p> For the record, I think std::string::erase() ought to handle npos, and I'm disappointed that it doesn't. Your code is more elegant than the fix: it's clear that you don't want to erase anything if you don't find what you're looking for. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Tue, 12 Oct 2010 18:39:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4685#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4685#comment:4</guid> <description> <p> I've committed some changes to trunk, does this solve the problem? </p> </description> <category>Ticket</category> </item> <item> <author>jim@…</author> <pubDate>Thu, 14 Oct 2010 09:27:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4685#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4685#comment:5</guid> <description> <p> All trunk tests now pass under msvc-8.0, as you can see from last night's test. Good job! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 14 Oct 2010 09:43:18 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4685#comment:6 https://svn.boost.org/trac10/ticket/4685#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket