Reputation: 25
#include <bits/stdc++.h>
using namespace std;
int main() {
cout << 5 << endl;
vector<int> v; cout << v[-1];
}
I am using zsh
on Mac. When I compile and run A.cpp
(shown above) with g++-9 -o A A.cpp && ./A
, the result is as follows:
5
zsh: segmentation fault ./A
However, when I define a function in .zshenv
(shown below) and run it, only 5
is printed.
RUN() {
g++-9 -o A A.cpp && ./A
}
What should I do to make the segmentation fault message also display?
Upvotes: 1
Views: 485
Reputation: 25
As mentioned in John's link (Displaying or redirecting a shell's job control messages) it seems that adding & fg
suffices.
Upvotes: 1