Problems with c++ library on iOS arm64e device

Compiler: XCode12/13/14
Tested On: iPhoneXS+iOS15.4 / iPhone11+iOS16.5 I tried to compile following code with arch=arm64e and run, it crashed with EXC_BAD_ACCESS at 'LDRAA', seems occur when trying to access c++ v-table. And this bug will not occur in following conditions. c++ I/O api is easy to trigger the bug.

  • compile with arch=arm64 and run on arm64e device
  • compile with arch=arm64e and run on arm64e device with iOS<=14
#include <fstream>
#include <stringstream>
int main(int argc, char** argv) {
    std::ifstream MyReadFile("/System/Library/CoreServices/SystemVersion.plist"); // crash1
    std::stringstream stream;
    stream << std::hex << 0; // crash2
}

I also tried c++11/14/17/20, it makes no difference.

Problems with c++ library on iOS arm64e device
 
 
Q