Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's because the 1 instruction variant may read past the end of an array. Let's say s is a single null byte at 0x2000fff, for example (and that memory is only mapped through 0x2001000); the function as written is fine, but the optimized version may page fault.


Ah, yes, good point. I think this is a nice example of "I didn't notice I needed to tell the compiler a thing I know so it can optimize".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: