This is a weird issue that I can't seem to find an answer to. This:
#include <iostream>
using namespace std;
void show_number(int number) {
cout << number << endl; // Shows '10' as expected
}
int main() {
cout << endl; // Remove this and it fails
__asm {
mov rdi, 10
call show_number
}
}
actually works fine, except when you remove the initial cout << endl
(first line of main
). When you remove it, the cout
in show_number
seems to cause a segfault for some reason.
What causes this?
(OSX Mavericks x64, but should work in linux as well I think)