[Boost.Filesystem] Is there any bug in ofstream implementation ?

Hi, I not pretty sure but it seems that there is a bug (?) somewhere in boost::filesystem::ofstream implementation in the Boost 1.34.1 release; to exhibit this behaviour, the snippet code hereafter trigger an assert in the last block: int main(int /*argc*/, char* /*argv[]*/) { const fs::path p("c:/temp/test.txt") ; const fs::wpath wp(L"c:/temp/test.txt") ; { fs::remove(p) ; fs::ofstream ofile(p) ; assert(!ofile.fail()) ; } { fs::remove(p) ; fs::ofstream ofile(wp) ; assert(!ofile.fail()) ; } { fs::remove(p) ; fs::ofstream ofile(p, std::ios_base::binary) ; assert(!ofile.fail()) ; } { fs::remove(p) ; fs::ofstream ofile(wp, std::ios_base::binary) ; assert(!ofile.fail()) ; // <-- Assert triggered here } } Running conditions: Boost 1.34.1 Visual C++ 7.1 Windows XP I'm waiting for your feedback. Best regards, Marc VIALA

[Marc Viala] I've replaced slashes by black-slashes in fs::path (p and wp) to confirm the same behaviour: I've got an assert at the same code line. My feeling is that the default opening mode "std::ios_base::out" in conjunction with fs::ofstream is overwritten; for example, if someone replace the last "ofile" declaration with that one: fs::ofstream ofile(wp, std::ios_base::binary| std::ios_base::out) every thing work fine!! Best regards, Marc VIALA
participants (2)
-
Marc Viala Perso
-
Steven Watanabe