[erlang-questions] Bit Syntax and compiler Erlang/OTP R21.1
Valentin Micic
v@REDACTED
Tue Aug 20 14:26:01 CEST 2019
Hi all,
Recently I’ve made a silly mistake. I wrote:
case Payload of
<<_:4/binary-unit:8, _:255, _:7/binary-unit:8, 0:16>> -> Payload;
_ -> throw( drop )
end
Instead of:
case Payload of
<<_:4/binary-unit:8, 255:8, _:7/binary-unit:8, 0:16>> -> Payload;
_ -> throw( drop )
end
Considering that overall pattern (which erroneously references 255 bits long field, instead of an octet with a value of 255 ) is not aligned to 8-bit boundary, is it unreasonable to expect the compiler to report this as a potential problem, or at least generate a warning (support for bit-fields notwithstanding).
What am I missing here?
V/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190820/f7cd47cc/attachment.htm>
More information about the erlang-questions
mailing list