my two cents doing some tests about Arm on Mac and in general exception.
this code:
#include <stdio.h> int main() { int a = 10; int b = 0; int c = a/b; printf("Hello, World!\n"); return 0; }
a) on macOS with M1/2 AND Xcode /clang simply set c to 0. No kind of Hw exception or error
b) on linux AND Intel you get usual: Floating point exception (core dumped)
c) (as expected..) using C++ and exception You cannot intercept divide by zero exception (of course on intel.. on Arm never generated)
#include <stdio.h> #include <exception> using namespace std; int main() { int a = 10; int b = 0; int c; try { c = a/b; } catch (int e) { cout << "AW! \n" << e << endl; } cout << ("Hello, World!++ \n"); return 0; }
D) note: this can be very confusing if you arrive or go to JAVA, where you can also catch Hw exception.
E) if you set target to x86_64 (even on M1!) You got: "Thread 1: EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)"
Hope can help some others.