Skip to content

[22876] Make optional copy/move constructors actuate only if the storage is engaged#264

Merged
Mario-DL merged 2 commits intomasterfrom
feature/22876
Mar 19, 2025
Merged

[22876] Make optional copy/move constructors actuate only if the storage is engaged#264
Mario-DL merged 2 commits intomasterfrom
feature/22876

Conversation

@Mario-DL
Copy link
Copy Markdown
Contributor

@Mario-DL Mario-DL commented Mar 19, 2025

Description

This PR makes optional copy/move constructors from other optionals to actuate only if the storage to copy from is engaged.
This prevents undefined behavior in the placement new when copying/moving data that is not initialized.
Specially, it tends to throw std::bad_array_new_length when trying to copy vectors.

@Mergifyio backport 2.2.x

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: CI pass and failing tests are unrelated with the changes.

Signed-off-by: Mario Dominguez <[email protected]>
@Mario-DL Mario-DL marked this pull request as ready for review March 19, 2025 07:51
@Mario-DL Mario-DL requested review from richiprosima and removed request for richiprosima March 19, 2025 07:53
@MiguelCompany MiguelCompany self-requested a review March 19, 2025 08:12
@Mario-DL Mario-DL merged commit 36c28c4 into master Mar 19, 2025
@Mario-DL Mario-DL deleted the feature/22876 branch March 19, 2025 08:40
@Mario-DL
Copy link
Copy Markdown
Contributor Author

@Mergifyio backport 2.2.x

@mergify
Copy link
Copy Markdown

mergify Bot commented Mar 19, 2025

backport 2.2.x

✅ Backports have been created

Details

mergify Bot pushed a commit that referenced this pull request Mar 19, 2025
… engaged (#264)

* Refs #22876: Add test

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #22876: Make optionals copy/move constructors actuate only if the storage is engaged.

Signed-off-by: Mario Dominguez <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
(cherry picked from commit 36c28c4)
MiguelCompany pushed a commit that referenced this pull request Mar 19, 2025
… engaged (#264) (#265)

* Refs #22876: Add test

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #22876: Make optionals copy/move constructors actuate only if the storage is engaged.

Signed-off-by: Mario Dominguez <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
(cherry picked from commit 36c28c4)

Co-authored-by: Mario Domínguez López <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants