Skip to content

Conversation

@rener2020
Copy link

@rener2020 rener2020 commented Oct 28, 2025

fix(Cdr): silence -Wconversion warning when updating options_[1]

Explicitly cast arithmetic expression to uint8_t to prevent narrowing conversion warning in GCC/Clang:

warning: conversion from ‘int’ to ‘std::array<unsigned char, 2>::value_type’ may change value [-Wconversion]

The new expression keeps the same semantics while ensuring type safety:

options_[1] = static_cast<uint8_t>(
    static_cast<uint8_t>(options_[1] & 0xC) +
    static_cast<uint8_t>(alignment & 0x3)
);

No behavioral change intended.

Description

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.
  • 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.

fix(Cdr): silence -Wconversion warning when updating options_[1]

Explicitly cast arithmetic expression to uint8_t to prevent narrowing
conversion warning in GCC/Clang:

    warning: conversion from ‘int’ to ‘std::array<unsigned char, 2>::value_type’ may change value [-Wconversion]

The new expression keeps the same semantics while ensuring type safety:

    options_[1] = static_cast<uint8_t>(
        static_cast<uint8_t>(options_[1] & 0xC) +
        static_cast<uint8_t>(alignment & 0x3)
    );

No behavioral change intended.


Signed-off-by: rener2020 <76736114+rener2020@users.noreply.github.com>
@rener2020 rener2020 closed this Oct 28, 2025
@rener2020 rener2020 reopened this Oct 28, 2025
@rener2020
Copy link
Author

@rener2020 rener2020 closed this Oct 30, 2025
@rener2020 rener2020 reopened this Oct 30, 2025
@rener2020 rener2020 marked this pull request as draft October 30, 2025 10:07
@rener2020 rener2020 marked this pull request as ready for review October 30, 2025 10:07
@rener2020 rener2020 marked this pull request as draft October 30, 2025 10:07
@rener2020 rener2020 marked this pull request as ready for review October 30, 2025 10:08
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 this pull request may close these issues.

1 participant