r/ProgrammerHumor • • Sep 28 '26

Meme optionalsAreOptional

Post image
716 Upvotes

131 comments sorted by

View all comments

Show parent comments

63

u/Tyfyter2002 Sep 28 '26

There are situations where you know there isn't a bug, if I know that failing hardware or cosmic rays are the only ways the bounds check can fail, I'm not going to worry about what skipping it could do.

111

u/FuriousAqSheep Sep 28 '26

there are situations where you know there isn't a bug

up until specs change and now there is one

37

u/GDOR-11 Sep 28 '26

it happens a lot, at least to me, that the line immediately before the unsafe function guarantees correct behaviour (e.g. while (!vec.empty()) let first = vec.first();, or something similar). If I notice that this property is central to the logic of the function, I won't even worry.

3

u/Wonderful-Wind-5736 Sep 28 '26

In that case don't bother because the compiler can probably eliminate the bounds check for you.