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

Variable length encoding fails the simpler test #40

Open
lrodorigo opened this issue Jun 4, 2024 · 1 comment
Open

Variable length encoding fails the simpler test #40

lrodorigo opened this issue Jun 4, 2024 · 1 comment

Comments

@lrodorigo
Copy link

lrodorigo commented Jun 4, 2024

The source code is quite self-explaining.
The code is properly working if the fixed-length econding is enable.
Linux - GCC v 14.1.1 - Current master branch.
Really scaring.

#include "alpaca/alpaca.h"

struct Simple {
    uint32_t field {0};
};

int main() {
    Simple data {0x12345678};

    std::vector<uint8_t> bytes;
    auto size = alpaca::serialize(data, bytes);

    std::error_code err;
    auto reconstructed = alpaca::deserialize<Simple>(bytes, err);

    assert(!err);
    
    assert(reconstructed.field == data.field); // And here it dies.
}
@p-ranav
Copy link
Owner

p-ranav commented Jun 5, 2024

Seems like an overflow bug in the 7-bit encoding. Thanks for encoding, I'll investigate.

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