Phix - bytes_to_int
- Posted by lesterb Jul 13, 2018
- 1207 views
Hi Pete,
I was trying to resurrect some stuff I wrote for Eu3 in 2012 and came across this anomaly. I made this little test program to demonstrate (the actual code is much larger).
--/* include machine.e --*/ integer test_out sequence test_in test_in = {22} test_out = bytes_to_int(test_in & repeat(0,4)) print(1, test_out) -- vim: ft=phix:
bytes_to_int behaves differently in Eu3 and Phix.
I note the doc description is also slightly different.
I also admit that my failing code is at best 'lazy' in extending the test_in sequence by at least 4 bytes.
In this case, the input to bytes_to_int is actually 5 bytes {22,0,0,0,0}.
The last (unnecessary) byte is ignored by Eu3 but causes an exception in Phix as follows...
--Result with Eu3.1 22 --Result with Phix (warning: lineno of -1 for era of #0060CF5F) fatal exception #80000003 at #0060CF5F Global & Local Variables
Changing the input to {22,0,0,0} makes it work in both.
I had a quick look at the code for bytes_to_int and it doesn't look like it should fail.
I don't know whether this can be classed as a bug or just a difference - I found it by writing sloppy code.
I shall go and fall on my coding pencil now.
Les