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] Warning about definition of implicit copy constructor #411

Open
2 tasks done
PhilippHaefele opened this issue Feb 23, 2024 · 3 comments
Open
2 tasks done

[BUG] Warning about definition of implicit copy constructor #411

PhilippHaefele opened this issue Feb 23, 2024 · 3 comments
Labels

Comments

@PhilippHaefele
Copy link

PhilippHaefele commented Feb 23, 2024

Describe the bug

Currently the code uses implicit generation of the copy constructors in some places.
Since C++11 this is declared as deprecated and therefore troughs warnings.

In my build I do see the warning at erpc_c/infra/erpc_message_buffer.hpp Line 57, but ther might be more places.

To Reproduce

compile sources with -Wall -Wextra or -Wdeprecated-copy in GCC (we use gcc-arm-none-eabi-10.3-2021.10)

Expected behavior

No -Wdeprecated-copy warning are in build output

Desktop

  • OS: Build machine is Windows (GCC cross-compiled compiled for own eRPC uC/OS-II port, but shouldn't matter at all for this issue)
  • eRPC Version: 1.12.0

Steps you didn't forgot to do

  • I checked if there is no related issue opened/closed.
  • I checked that there doesn't exist opened PR which is solving this issue.

Additional context

If I'm right it should be enough to add = default to the corresponding copy-constructors (available since C++11)

In VS Code i did use following regex to search for copy constructors (?<=\s|^)(\w+)(\(.*\1.*&.+\)) and there seems to be only the above mentioned one in the C/C++ integration code, that is not there to "delete" / hide the copy constructor (they could also be deleted with a = delete).

Not 100% sure if this change is feasible and results in the expected behavior.

Update:
Should be fairly simply to fix by adding (not 100% sure, as I'm not a C++ expert):

MessageBuffer &operator=(const MessageBuffer &buffer);
MessageBuffer &erpc::MessageBuffer::operator=(const MessageBuffer &buffer)
{
    m_buf = buffer.m_buf;
    m_len = buffer.m_len;
    m_used = buffer.m_used;

    return *this;
}
Copy link

Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.

@PhilippHaefele PhilippHaefele changed the title [BUG] [BUG] Warning about definition of implicit copy constructor Feb 23, 2024
@PhilippHaefele
Copy link
Author

@Hadatko @MichalPrincNXP Any thoughts on this and/or should I create a PR for this?

@PhilippHaefele
Copy link
Author

When changing API to suggested one in #416 it's maybe not needed anymore

@MichalPrincNXP @Hadatko Any thoughts on one of the two issues (this on and #416) ?

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

No branches or pull requests

1 participant