[cfe-dev] libc++ fails to build with exception disabled

Konstantin Tokarev annulen at yandex.ru
Mon Jun 11 10:00:37 PDT 2012



11.06.2012, 19:24, "Konstantin Tokarev" <annulen at yandex.ru>:
> Hi all,
>
> I've tried to build libc++ on Linux using clang with LIBCXX_ENABLE_EXCEPTIONS=OFF in CMake-based build system, but got compilation error:
>
> cd /home/kostya/src/git/libcxx/build-noexcept/lib && /usr/local/bin/clang++   -Dcxx_EXPORTS -D_LIBCPP_NO_EXCEPTIONS -DNDEBUG -fPIC -I/home/kostya/src/git/libcxx/include    -nostdinc++ -std=c++0x -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long -fno-exceptions -fPIC -o CMakeFiles/cxx.dir/__/src/debug.cpp.o -c /home/kostya/src/git/libcxx/src/debug.cpp
> /home/kostya/src/git/libcxx/src/debug.cpp:149:13: error: cannot use 'throw' with exceptions disabled
>             throw bad_alloc();
>             ^
> /home/kostya/src/git/libcxx/src/debug.cpp:170:9: error: cannot use 'throw' with exceptions disabled
>         throw bad_alloc();
>         ^
> /home/kostya/src/git/libcxx/src/debug.cpp:405:13: error: cannot use 'throw' with exceptions disabled
>             throw bad_alloc();
>             ^
> /home/kostya/src/git/libcxx/src/debug.cpp:427:13: error: cannot use 'throw' with exceptions disabled
>             throw bad_alloc();
>             ^
> /home/kostya/src/git/libcxx/src/debug.cpp:448:9: error: cannot use 'throw' with exceptions disabled
>         throw bad_alloc();
>         ^
> 5 errors generated.
>
> Is it a bug or LIBCXX_ENABLE_EXCEPTIONS option is not supported and should be removed?

It also fails to build with disabled c++0x:

cd /home/kostya/src/git/libcxx/build-noc++11/lib && /usr/local/bin/clang++   -Dcxx_EXPORTS -DNDEBUG -fPIC -I/home/kostya/src/git/libcxx/include    -nostdinc++ -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long -pedantic -fPIC -DLIBCXXRT -I/usr/local/src/libcxx/lib -o CMakeFiles/cxx.dir/__/src/future.cpp.o -c /home/kostya/src/git/libcxx/src/future.cpp
/home/kostya/src/git/libcxx/src/future.cpp:13:1: warning: inline namespaces are a C++11 feature [-Wc++11-extensions]
_LIBCPP_BEGIN_NAMESPACE_STD
^
/home/kostya/src/git/libcxx/include/__config:266:52: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_STD'
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
                                                   ^
/home/kostya/src/git/libcxx/src/future.cpp:32:13: error: no matching conversion for static_cast from 'int' to 'std::__1::future_errc'
    switch (static_cast<future_errc>(ev))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kostya/src/git/libcxx/include/future:379:29: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to
      'const std::__1::future_errc' for 1st argument;
_LIBCPP_DECLARE_STRONG_ENUM(future_errc)
                            ^
/home/kostya/src/git/libcxx/include/__config:404:63: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM'
#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum _
                                                              ^
/home/kostya/src/git/libcxx/include/future:386:36: note: candidate constructor not viable: no known conversion from 'int' to 'std::__1::future_errc::_' for 1st
      argument;
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
                                   ^
/home/kostya/src/git/libcxx/include/__config:407:27: note: expanded from macro '_LIBCPP_DECLARE_STRONG_ENUM_EPILOG'
    _LIBCPP_ALWAYS_INLINE x(_ __v) : __v_(__v) {} \
                          ^
1 warning and 1 error generated.

-- 
Regards,
Konstantin



More information about the cfe-dev mailing list