Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#5152 closed Bugs (wontfix)

Inconsistent behavior of path.native() function

Reported by: lcarreon@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.45.0 Severity: Problem
Keywords: Cc:

Description

Hi,

I have built the 32-bit and 64-bit Boost libraries on Windows, Fedora Linux and Solaris 10 x86 using the following options:

runtime-link=shared link=shared

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.

Here's the result of test_path.cpp on Windows:

Current directory path:

generic_string = "C:/Devel/projects/compiler_tests/test_path" native = "C:\Devel\projects\compiler_tests\test_path"

Parent of current directory path:

generic_string = "C:/Devel/projects/compiler_tests" native = "C:\Devel\projects\compiler_tests"

Here's the result of test_path.cpp on Fedora Linux:

Current directory path:

generic_string = "/home/Leo/Devel/projects/compiler_tests/test_path" native = /home/Leo/Devel/projects/compiler_tests/test_path

Parent of current directory path:

generic_string = "/home/Leo/Devel/projects/compiler_tests" native = /home/Leo/Devel/projects/compiler_tests

Here's the result of test_path.cpp on Solaris 10 x86:

Current directory path:

generic_string = "/home/Leo/Devel/projects/compiler_tests/test_path" native = /home/Leo/Devel/projects/compiler_tests/test_path

Parent of current directory path:

generic_string = "/home/Leo/Devel/projects/compiler_tests" native = /home/Leo/Devel/projects/compiler_tests

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.

Was this difference in behavior intentional or is it a bug?

Regards, Leo

Attachments (1)

test_path.cpp (650 bytes ) - added by lcarreon@… 12 years ago.

Download all attachments as: .zip

Change History (3)

by lcarreon@…, 12 years ago

Attachment: test_path.cpp added

comment:1 by anonymous, 12 years ago

Resolution: wontfix
Status: newclosed

This was a real head scratcher!

  1. Your test program outputs quotes around the generic_string example but not around the native example. That confuses the other issues.
  1. native() returns const string_type&. 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...
  1. Your test program is sloppy about namespaces:

using namespace std; using namespace boost::filesystem;

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 <<.

  1. Operator << with a path correctly places quotes around the output string, resulting in the output you are seeing on Windows.

While it might be nice to poison path::operator<<(), that isn't really a bug in class path so I'm closing this as "won't fix".

--Beman

comment:2 by lcarreon@…, 12 years ago

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.

Note: See TracTickets for help on using tickets.