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

Bug when using std::vector in place of variable-length array type. #298

Open
hungatamazon opened this issue Mar 29, 2023 · 1 comment
Open

Comments

@hungatamazon
Copy link

When following https://nunavut.readthedocs.io/en/latest/docs/languages.html to use std::vector instead of variable_length_array, there is a bug in the generated code.

The generated header has the intended type. Example: std::vectorstd::uint32_t value{}; . But it's trying to push_back() with no argument in the deserialize code.

    std::vector<std::uint32_t> value{};

...

    nunavut::support::SerializeResult
    deserialize(nunavut::support::const_bitspan in_buffer)
    {

     ...

            for (size_t _index5_ = 0U; _index5_ < _size0_; ++_index5_)
            {
                // TODO This is terribly inefficient. We need to completely refactor this template to use C++ emplace and
                // move semantics instead of assuming C-style containers
                value.push_back();   // <--- This causes compiler errors
                value[_index5_] = in_buffer.getU32(32U);
                in_buffer.add_offset(32U);
            }

      ...

    }
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Mar 29, 2023
@thirtytwobits
Copy link
Member

Confirmed this is a bug (sorry) and have a fast fix in my fork (thirtytwobits@ed93979) but I'd like to massage out that TODO This is terribly inefficient... comment as part of this fix.

thirtytwobits added a commit that referenced this issue May 18, 2023
#298 will be fixed but this will also get another refactor when we
switch to CETL.
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