Boost C++ Libraries: Ticket #10766: boost::filesystem::path::parent_path() with redundant separator returns wrong value https://svn.boost.org/trac10/ticket/10766 <p> boost::filesystem::path::parent_path() function with redundant separator at the end of directory don't return parent directory, it just removes this separator. </p> <p> Ubuntu 12.04, gcc 4.6.3 </p> <p> Following test fails: </p> <div class="wiki-code"> <div class="diff"> <ul class="entries"> <li class="entry"> <h2> <a>test/path_unit_test.cpp</a> </h2> <pre>diff --git test/path_unit_test.cpp test/path_unit_test.cpp index 67ccb9f..09c7f34 100644</pre> <table class="trac-diff inline" cellspacing="0"> <colgroup> <col class="lineno"/><col class="lineno"/><col class="content"/> </colgroup> <thead> <tr> <th title="File test/path_unit_test.cpp"> </th> <th title="File test/path_unit_test.cpp"> </th> <td> <em> namespace</em> &nbsp; </td> </tr> </thead> <tbody class="unmod"> <tr> <th>662</th><th>662</th><td class="l"><span>&nbsp; &nbsp; CHECK(path("/").parent_path().string() == "");</span></td> </tr> <tr> <th>663</th><th>663</th><td class="l"><span>&nbsp; &nbsp; CHECK(path("/foo").parent_path().string() == "/");</span></td> </tr> <tr> <th>664</th><th>664</th><td class="l"><span>&nbsp; &nbsp; CHECK(path("/foo/bar").parent_path().string() == "/foo");</span></td> </tr> </tbody> <tbody class="add"> <tr class="last first"> <th>&nbsp;</th><th>665</th><td class="r"><ins>&nbsp; &nbsp; CHECK(path("/foo/bar/").parent_path().string() == "/foo");</ins></td> </tr> </tbody> <tbody class="unmod"> <tr> <th>665</th><th>666</th><td class="l"><span></span></td> </tr> <tr> <th>666</th><th>667</th><td class="l"><span>&nbsp; &nbsp; CHECK(path("/foo/bar/baz.zoo").filename().string() == "baz.zoo");</span></td> </tr> <tr> <th>667</th><th>668</th><td class="l"><span></span></td> </tr> </tbody> </table> </li> </ul> </div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10766 Trac 1.4.3 Renu Tyagi <renu.tyagi@…> Wed, 27 May 2015 03:25:55 GMT attachment set https://svn.boost.org/trac10/ticket/10766 https://svn.boost.org/trac10/ticket/10766 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_10766_fixbug.patch</span> </li> </ul> <p> Patch for bug. </p> Ticket Renu Tyagi <renu.tyagi@…> Wed, 27 May 2015 03:29:53 GMT attachment set https://svn.boost.org/trac10/ticket/10766 https://svn.boost.org/trac10/ticket/10766 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_10766_fixtest.patch</span> </li> </ul> <p> As per my finding Boost considers parent path of /foo/ as /foo and not just /. This is shown in /libs/filesystem/path_test.cpp . But if still it is a bug, then here is the patch for bug and corresponding patch for path_test.cpp. </p> Ticket Beman Dawes Thu, 03 Sep 2015 14:45:08 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10766#comment:1 https://svn.boost.org/trac10/ticket/10766#comment:1 <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> <p> The behavior is correct, so there no bug in that sense. </p> <p> There is a bug, however, in the sense that the reference documentation is unclear. To fix that, examples and notes have been added to the reference documentation to show why the returned value is in fact correct, and to provide rationale for that behavior. See [path.itr], and [path.decompose] parent_path() and filename() sections of the reference docs. </p> <p> As a result of those doc changes, this issue is being marked as "fixed" rather than "invalid". </p> <p> Thanks, </p> <p> --Beman </p> Ticket