Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayLength attribute doesn't work properly on char[] array #14

Open
togrue opened this issue Aug 15, 2016 · 1 comment
Open

ArrayLength attribute doesn't work properly on char[] array #14

togrue opened this issue Aug 15, 2016 · 1 comment

Comments

@togrue
Copy link

togrue commented Aug 15, 2016

The following Testcase fails at runtime:

struct TestStruct {
    ubyte len;
    @ArrayLength("len") char[] foo;
}

auto decerealiser = Decerealiser([2, 1, 2]);
// CerealException: "@ArrayLength of 2 units of type dchar (4 bytes) larger than remaining byte array (2 bytes)"
auto ts = decerealiser.value!TestStruct;
assert(ts.foo == ['\x01', '\x02']);
assert(ts.foo.length == 2);
@atilaneves
Copy link
Owner

I think you can blame this one on auto-decoding. I suggest using ubyte instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants