Basic C++ program in Xcode results in Thread 1: EXC_BAD_ACCESS code=2

Viewed 41

In Xcode 11.3 on OS X 11.7, I am trying to run the most basic C++ program:

int main(int argc, char * argv[]) {
    return 0;
}

The Product->Build succeeds just fine.

Product->Run results in Thread 1: EXC_BAD_ACCESS (code=2 ...)

In the Scheme for "Run", I have both Address Sanitizer and Zombie Objects checked, as suggested by other answers to more complicated programs, with no change in the error.

Something fundamental must be misconfigured, but i am new to Xcode and am out of obvious places to look.

Edit: I have just verified that building and running on the command line work as expected:

g++ main.cpp -o main
./main

Update 2: Problem seems to be when "Debug executable" is checked in the scheme. When running the Scheme, title bar hangs at "Waiting to attach to ...". Unchecking the box allows the program to run, but this is not a fix as I wouldn't be able to debug when needed.

0 Answers
Related