Skip to content

Conversation

@ssam18
Copy link

@ssam18 ssam18 commented Nov 12, 2025

This fixes #392 where MSVC was throwing a C4242 warning about converting from unsigned int to BYTE.

I hit this issue when compiling with /WX (treat warnings as errors). The warning happens because value_ is unsigned int but storage.ByteSize expects a BYTE.

The fix is simple - just add a static_cast. The cast is safe since character_size values are always in the valid range (5, 6, 7, or 8 bits).

Tested that this compiles cleanly on MSVC 2019 with /W4.

Add static_cast<BYTE> to avoid MSVC warning C4242 when converting
from unsigned int to BYTE in character_size::store(). This warning
causes issues for projects that treat warnings as errors.

The cast is safe since character_size values are always in the valid
BYTE range (typically 5, 6, 7, or 8).

Fixes boostorg#392
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.

C4242 warning at line 511 in serial_port_base.ipp

1 participant