3 ms·
Nope, that's just UB, so you cannot know what the code will do. Case in point, running it on linux (compiled via clang) doesn't trigger a segvault for me:
by skitter 3y ago
Nope, that's just UB, so you cannot know what the code will do. Case in point, running it on linux (compiled via clang) doesn't trigger a segvault for me:
main:
.cfi_startproc
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
- junon 3y agoTo be fair, that's because it was optimized out. Mark it as volatile and try again. It will almost definitely segfault. The other points still stand, though - that's just because Linux is forced to respond to a page fault exception and chooses to signal that to the process.