nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

libcxxabi: libcxxabi enables exceptions by default

Open Gary-Hobson opened this issue 6 months ago • 0 comments

Summary

In the following code, even though the application does not use exceptions, an exception is still thrown in libcxx

If libcxxabi is not enabled, the toolchain default implementation will be used. However, arm-gcc does not enable thread support by default, which will cause errors in a multi-threaded environment.

Therefore, we need to use libcxxabi to ensure normal functions in a multi-threaded environment.

  using namespace std;
  
  void foo(bool recur);
  int bar(bool recur)
  {
    if (recur) {
        foo(false);
    }
    return 0xFAFAFA;
  }
  
  void foo(bool recur)
  {
    static int i = bar(recur);
    cout << "Static is:" << i << "\n";
  }
  
  int main(int argc, char *argv[])
  {
    foo(true);
    return 0;
  }

Impact

Testing

Gary-Hobson avatar Aug 22 '24 14:08 Gary-Hobson