title: Android NDK R5 and support of C++ exception
body: <p>I am trying to use the NDK 5 full C++ gnustl:</p>
  
  <p>The <code>CPLUSPLUS-SUPPORT.html</code> states:</p>
  
  <blockquote>
    <p>The NDK toolchain supports C++ exceptions, since NDK r5, however all C++
    sources are compiled with -fno-exceptions support by default, for
    compatibility reasons with previous releases.</p>
    
    <p>To enable it, use the '-fexceptions' C++ compiler flag. This can be done
    by adding the following to every module definition in your Android.mk:</p>
  
  <pre><code>LOCAL_CPPFLAGS += -fexceptions
  </code></pre>
    
    <p>More simply, add a single line to your Application.mk, the setting will
    automatically apply to all your project's NDK modules:</p>
  
  <pre><code>APP_CPPFLAGS += -fexceptions
  </code></pre>
  </blockquote>
  
  <p><code>sources/cxx-stl/gnu-libstdc++/README</code> states:</p>
  
  <blockquote>
    <p>This directory contains the headers and prebuilt binaries for the
    GNU libstdc++-v3 C++ Standard Template Library implementation.</p>
    
    <p>These are generated from the toolchain sources by the rebuild-all-prebuilt.sh
    script under build/tools.</p>
    
    <p>To use it, define APP_STL to 'gnustl_static' in your Application.mk.
    See docs/CPLUSPLUS-SUPPORT.html for more details.</p>
    
    <p>This implementation fully supports C++ exceptions and RTTI.</p>
  </blockquote>
  
  <p>But all attempts using exceptions fail. An alternative NDK exists on <a href="http://www.crystax.net/android/ndk-r4.php">http://www.crystax.net/android/ndk-r4.php</a>. Using the the hello-jni example from that NDK does not work. Compliation with NDK 5 works after creating an <code>Application.xml</code> with</p>
  
  <pre><code>APP_STL := gnustl_static
  </code></pre>
  
  <p>Setting APP_STL to <code>gnustl_static</code> also automatically enables <code>-frtti</code> and <code>-fexceptions</code>. But it dies the same horrific death as my own experiments. </p>
  
  <p>I have managed to get a minimal example of code that is crashing for me:</p>
  
  <pre><code>try {
      __android_log_write(ANDROID_LOG_DEBUG,"foobar","trhown!");
      throw "Wrong object type.";
  } catch (char* b) {
      __android_log_write(ANDROID_LOG_DEBUG,"foobar","catched!");
  }
  </code></pre>
  
  <p>Am I am missing something or is the statement in the <code>README</code> and <code>CPLUSPLUS-SUPPORT.html</code> just plain wrong?</p>