Why is that output a “Bus error: 10” in a boost program (boost::filesystem)?

I successfully compile the program at the Question How to pass a string type path to boost::filesystem:path's constructor? However, the output result shows more than the expected one.

Folder status: 0
Bus error: 10

The first line is the only expected result. I do not understand why the second one comes?

I get the following debug information by gdb:

(gdb) run
Starting program: /Users/ZL/Desktop/mtfsg 
Reading symbols for shared libraries ++++............................. done
Folder status: 0

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5fc005a0
0x00007fff9046aab7 in std::basic_string<char, std::char_traits<char>, 
std::allocator<char>>::~basic_string ()
(gdb) bt
#0  0x00007fff9046aab7 in std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::~basic_string ()
#1  0x00000001000018dd in main () at m.cpp:12

Answers


Finally, I find the point of the error in my code:

In class OSxFS (tfs.h file), the method "string ShowStatus()" has an incorrect return type "string". This method does not need a return value since its functionality is only to print the directory (folder) status on the screen. So, I replace the "string" return type by "void".

The original code of method "string ShowStatus()"

**string** ShowStatus()
    {
      boost::filesystem::file_status folderStatus =
       boost::filesystem::status(mFolderPath);

      try
      {
        cout<<"Folder status: "<<boost::filesystem::is_directory(folderStatus)<<endl;
      }
      catch(boost::filesystem::filesystem_error &e)
      {
        cerr<<"Error captured: "<<e.what()<<endl;
      }
    }

The correct code:

**void** ShowStatus()
    {
      boost::filesystem::file_status folderStatus = 
       boost::filesystem::status(mFolderPath);

      try
      {
        cout<<"Folder status: "<<boost::filesystem::is_directory(folderStatus)<<endl;
      }
      catch(boost::filesystem::filesystem_error &e)
      {
        cerr<<"Error captured: "<<e.what()<<endl;
      }
    }

Need Your Help

ASP .NET MVC What's going on with my route?

asp.net-mvc asp.net-mvc-routing

I have a problem, my url is ugly smth like this:

Is MVC necessary for a client-server application?

java model-view-controller client-server

Currently doing a group project for college in Java. The assignment is to produce a zero-conf based distributed system. Our group decided on a conference chat application, using client-server

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.