See the man page:
On some hardware architectures (e.g., i386), PROT_WRITE implies PROT_READ.
You should not depend on this behavior.
Domanda
If I map a page as write only:
int* mem_location = (int*)mmap(nullptr, getpagesize(),
PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
cout << "Read @" << mem_location << ". This should segfault: "
<< *mem_location << endl;
cout << "doesn't though??" << endl;
why doesn't it segfault on read?
Soluzione
See the man page:
On some hardware architectures (e.g., i386), PROT_WRITE implies PROT_READ.
You should not depend on this behavior.