Is it safe to index a little bit out of bounds

Sven Panne svenpanne at gmail.com
Thu Mar 8 15:50:14 UTC 2018


2018-03-08 15:19 GMT+01:00 Andrew Martin <andrew.thaddeus at gmail.com>:

> [...] Some of the bytes in the word will have garbage in them. However,
> this could always be masked out with a bit mask (you have to know the
> platform endianness for this to work right). Is this safe? I doubt think
> this could ever cause a segfault but I wanted to check.
>

Before doing such things, please make sure that e.g. valgrind or similar
tools are happy with such Kung-Fu. I don't know off the top of my head how
fine-grained their checks are, but there is various similar code out there
in the wild which is a PITA to debug. You might force people to add
suppressions or even worse: Make some valuable tools totally useless. This
is not something which should be done lightly...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180308/29f307cd/attachment.html>


More information about the Libraries mailing list