<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/116015>116015</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Static library compiled with -no-rtti breaks exception handling in an executable it's linked into on ARM Mac
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Harrm
      </td>
    </tr>
</table>

<pre>
    Hi!

This issue is present on both Apple Clang 16 (Apple clang version 16.0.0 (clang-1600.0.26.3) and Clang 19 installed from Homebrew (Homebrew clang version 19.1.3).

It can be reproduced with a following code:

lib.cpp
```cpp
#include <stdexcept>

int foo(int x) {
    throw std::runtime_error("aaa");
    return x * x;
}
```

main.cpp
```cpp
#include <stdexcept>
#include <system_error>
#include <iostream>

int main() {
    try {
 throw std::system_error(std::make_error_code(std::errc::bad_address));
 } catch(std::runtime_error e) {
        std::cout << "Success\n";
    } catch(...) {
        std::cout << "Fail\n";
    }
}
```

I build it using the following flags:
```sh
clang++ -fno-rtti -o build/lib.o -c lib.cpp 
clang++ -o build/main_fail main.cpp build/lib.o
clang++ -o build/main_success main.cpp
```

On mac, main_success prints "Success" and main_fail prints "Fail", despite executing the same code.
It works fine (both print "Success") on Linux with clang 19.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV1v6zYM_TXyCxHDpp04efBDmi7oBXYxYHfvhSwxsVZZMiS5Sf_9IDsfTteLbVhRJAIlHpKH5An3Xh0NUc2WT2z5nPAhtNbVL9y5Lmms_KhfFMOcZc8s206ff7TKg_J-IFAeekeeTABroLGhhW3fa4Kd5uYI-QoYrieLGC3v5LyyBvJVmqVZvB3ti3yVZWmW4iotGG6AG3mF2IAyPnCtScLB2Q5ebEeNo1N0vp0_oW_SfARK53l_CyC4gYbAUe-sHARJOKnQAoeD1dqelDmCsJJYsZ07atWkou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