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

Integer value problem #16

Open
mengguang opened this issue Feb 20, 2023 · 0 comments
Open

Integer value problem #16

mengguang opened this issue Feb 20, 2023 · 0 comments

Comments

@mengguang
Copy link

I copyed the sample code and just change the value of c to UINT64_MAX, the assert failed.

#include <alpaca/alpaca.h>

int main() {

    struct MyStruct {
        char a;
        int b;
        uint64_t c;
        float d;
        bool e;
    };

    MyStruct s{ 'a', 5, UINT64_MAX, 3.14f, true };

    // Serialize
    std::vector<uint8_t> bytes;
    auto bytes_written = alpaca::serialize(s, bytes);

    // Deserialize
    std::error_code ec;
    auto recovered = alpaca::deserialize<MyStruct>(bytes, ec);
    assert((bool)ec == false);
    assert(recovered.a == 'a');
    assert(recovered.b == 5);
    assert(recovered.c == UINT64_MAX);
    assert(recovered.d == 3.14f);
    assert(recovered.e == true);
}

Is this a problem? My test environment is msvc2022.
I also tested the same code in Ubuntu 20.04.4 LTS and g++ version 9.4.0 , same result.

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

Successfully merging a pull request may close this issue.

1 participant