Boost C++ Libraries: Ticket #5152: Inconsistent behavior of path.native() function https://svn.boost.org/trac10/ticket/5152 <p> Hi, </p> <p> I have built the 32-bit and 64-bit Boost libraries on Windows, Fedora Linux and Solaris 10 x86 using the following options: </p> <blockquote> <p> runtime-link=shared link=shared </p> </blockquote> <p> I am noticing some difference in behavior with the path.native() function when I send it to a stream. To illustrate the problem, I'm attaching my test program test_path.cpp. </p> <p> Here's the result of test_path.cpp on Windows: </p> <blockquote> <p> Current directory path: </p> </blockquote> <blockquote> <blockquote> <p> generic_string = "C:/Devel/projects/compiler_tests/test_path" native = "C:\Devel\projects\compiler_tests\test_path" </p> </blockquote> </blockquote> <blockquote> <p> Parent of current directory path: </p> </blockquote> <blockquote> <blockquote> <p> generic_string = "C:/Devel/projects/compiler_tests" native = "C:\Devel\projects\compiler_tests" </p> </blockquote> </blockquote> <p> Here's the result of test_path.cpp on Fedora Linux: </p> <blockquote> <p> Current directory path: </p> </blockquote> <blockquote> <blockquote> <p> generic_string = "/home/Leo/Devel/projects/compiler_tests/test_path" native = /home/Leo/Devel/projects/compiler_tests/test_path </p> </blockquote> </blockquote> <blockquote> <p> Parent of current directory path: </p> </blockquote> <blockquote> <blockquote> <p> generic_string = "/home/Leo/Devel/projects/compiler_tests" native = /home/Leo/Devel/projects/compiler_tests </p> </blockquote> </blockquote> <p> Here's the result of test_path.cpp on Solaris 10 x86: </p> <blockquote> <p> Current directory path: </p> </blockquote> <blockquote> <blockquote> <p> generic_string = "/home/Leo/Devel/projects/compiler_tests/test_path" native = /home/Leo/Devel/projects/compiler_tests/test_path </p> </blockquote> </blockquote> <blockquote> <p> Parent of current directory path: </p> </blockquote> <blockquote> <blockquote> <p> generic_string = "/home/Leo/Devel/projects/compiler_tests" native = /home/Leo/Devel/projects/compiler_tests </p> </blockquote> </blockquote> <p> Please notice that in the 3 sets of results above, the Windows results show the native path enclosed in double quotes while it isn't on Fedora Linux and Solaris 10 x86. </p> <p> Was this difference in behavior intentional or is it a bug? </p> <p> Regards, Leo </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5152 Trac 1.4.3 lcarreon@… Wed, 02 Feb 2011 22:28:44 GMT attachment set https://svn.boost.org/trac10/ticket/5152 https://svn.boost.org/trac10/ticket/5152 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_path.cpp</span> </li> </ul> Ticket anonymous Fri, 04 Feb 2011 16:59:53 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5152#comment:1 https://svn.boost.org/trac10/ticket/5152#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">wontfix</span> </li> </ul> <p> This was a real head scratcher! </p> <ol><li>Your test program outputs quotes around the generic_string example but not around the native example. That confuses the other issues. </li></ol><ol start="2"><li>native() returns const string_type&amp;. On posix, string_type is std::string, so no problem. Windows, string_type is std::wstring, so outputting it to std::cout should result in a compile time error. But... </li></ol><ol start="3"><li>Your test program is sloppy about namespaces: </li></ol><blockquote> <p> using namespace std; using namespace boost::filesystem; </p> </blockquote> <blockquote> <p> On Windows, that lets the class path conversion from wstring to kick in via ADL, resulting in a path temporary which is then output to cout via operator &lt;&lt;. </p> </blockquote> <ol start="4"><li>Operator &lt;&lt; with a path correctly places quotes around the output string, resulting in the output you are seeing on Windows. </li></ol><p> While it might be nice to poison path::operator&lt;&lt;(), that isn't really a bug in class path so I'm closing this as "won't fix". </p> <p> --Beman </p> Ticket lcarreon@… Fri, 04 Feb 2011 23:37:28 GMT <link>https://svn.boost.org/trac10/ticket/5152#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5152#comment:2</guid> <description> <p> What confused me to use the native() function in my test program is the fact that on Windows the string() function insisted on displaying in generic format. Even the native() function did the same unless I invoked the make_preferred() function on the path. Thank you for your explanation, I'm switching my test program back to using the string() function. </p> </description> <category>Ticket</category> </item> </channel> </rss>