Boost logo

Boost Users :

Subject: [Boost-users] exceptions from boost::filesystem not catchable on os/x 10.6.8 boost-1.47.0
From: david x callaway (dxc_at_[hidden])
Date: 2011-09-04 17:51:42

os/x 10.6.8
uname -a
Darwin apple1 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386

boost 1.47.0
./ --prefix=$HOME/boost
./b2 link=static --disable-filesystem2 install # I've tried without disabling filesystem2, same result
gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

test app compiled:
g++ -Wall -I $HOME/boost/include fs.cpp -L$HOME/boost/lib -lboost_filesystem -lboost_system

otool -L a.out
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

source below. when I run it with a non-existent filename I expect to catch an exception, but instead nothing happens, i.e. I just return to the shell prompt. I tried defining a struct locally and throwing it and the catch works fine.

any ideas?


#include <iostream>
#include <stdlib.h>

#include "boost/filesystem.hpp"

int main(int argc, const char** argv)
    if(argc != 2)
        std::cout << "usage: a.out filename\n";

    const char* a_path = argv[1];

    catch(const boost::filesystem::filesystem_error& e)
        std::cout << "caught filesystem_error\n";
        std::cout << e.what() << "\n";
    catch(const std::exception& e)
        std::cout << "caught some other error\n";
        std::cout << e.what() << "\n";
        std::cout << "caught unknown exception\n";
    return 0;

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at