Re: [Boost-bugs] [Boost C++ Libraries] #6638: convert_aux fails while intializing global variable

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6638: convert_aux fails while intializing global variable
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-04-25 12:09:35


#6638: convert_aux fails while intializing global variable
-------------------------+-------------------------------------------------
  Reporter: john doe | Owner: bemandawes
  <johndoe> | Status: assigned
      Type: Bugs | Component: filesystem
 Milestone: To Be | Severity: Problem
  Determined | Keywords: filesystem path convert wide/narrow
   Version: Boost | string
  1.59.0 |
Resolution: |
-------------------------+-------------------------------------------------

Comment (by Leinad):

 Here is another crashing variation:

 {{{
 #include <boost\filesystem.hpp>

 class Alma
 {
 public:
         Alma() { /*boost::filesystem::exists("C:\\alma.txt");*/ }
         ~Alma() { std::cout <<
 boost::filesystem::path("c:\\alma.txt").string() << std::endl; }
 };

 class Korte
 {
 public:
         Korte() { boost::filesystem::exists("C:\\korte.txt"); }
         ~Korte() { std::cout <<
 boost::filesystem::path("c:\\korte.txt").string() << std::endl; }
 };

 Alma a;
 Korte k;

 int main(int argc, char* argv[])
 {
         return 0;
 }
 }}}

 Please note that the constructor body of Alma is empty.

 I wonder whether we could learn from these examples.

 In this case first {{{a}}}, then the static std local and facet stuff,
 then {{{k}}} created. Then at exit {{{k}}} destructed, then the static std
 local and facet stuff, then {{{a}}}. When {{{a}}} is destructed all the
 facet stuff is gone and that is why it crashes. Wouldn't it be better that
 in the path.hpp (or where it is appropriate) we had a static std::local
 instance instead of creating it lazily in the std::locale& path_locale()
 function?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6638#comment:11>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-04-25 12:13:52 UTC