ImHex
ImHex copied to clipboard
[Bug] std::mem::read_unsigned won't accept any endian but native
Operating System
Windows
What's the issue you encountered?
std::mem::read_unsigned takes an endianness parameter, but anything but the default (native endianness) returns this error:
error[E0012]: Built-in function error.
Invalid endian value.
hint: Try one of the values in the std::core::Endian enum.
The Endian enum seems to be only defined in std::mem.
Regardless of I use the enum or directly use the integer , the same error applies.
Only when I use 0 or std::mem:Endian::Native does it not throw.
How can the issue be reproduced?
In pattern editor:
#include <std/mem.pat>
fn Test(auto base) {
u32 x = std::mem::read_unsigned(base, 4, std::mem::Endian::Big);
}
ImHex Version
1.24.3
ImHex Build Type
- [X] Nightly or built from sources
Installation type
MSI
Additional context?
I'm not sure where to find the nightly commit hash; downloaded via https://imhex.werwolv.net/ .
Hey When you updated to the nightly build, did you also update the pattern language standard library in the Content Store? I just ran your script locally and it works fine here.
I used the nightly MSI installer.
For now I am manually byte-swapping... will try again when the #include fix is included in the next release.
I can confirm this happens on Linux too. Even with the #pragma directive
I can reproduce it only if the default endianness is set to Big (happens if set with a pragma directive or with std::core::set_endian). Cannot reproduce if it is set to Native or Little.
#include <std/io.pat>
#include <std/mem.pat>
#pragma endian big
std::print("{}", std::mem::read_unsigned($, 1, std::mem::Endian::Big));
Hey, I fixed a bug for a related issue a few days ago. Could you try downloading the latest nightly from https://imhex.werwolv.net and check if it still happens for you? I can't reproduce it myself anymore
It works correctly now, thank you!
Awesome thanks!