Fix C4242 warning in serial_port_base::character_size::store#460
Open
ssam18 wants to merge 1 commit intoboostorg:developfrom
Open
Fix C4242 warning in serial_port_base::character_size::store#460ssam18 wants to merge 1 commit intoboostorg:developfrom
ssam18 wants to merge 1 commit intoboostorg:developfrom
Conversation
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
Author
|
Can someone take a look on this PR? |
|
Looks good to me. |
|
@nigels-com - Thank you for reviewing this PR. I am going to pick up another issue to work on. If you have something that is urgent/important, please pass it on my way. I will work on that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.