Skip to content

inet_pton.c: Fix MSVC run-time check failure#387

Closed
MarcelRaad wants to merge 1 commit intocurl:masterfrom
MarcelRaad:patch-2
Closed

inet_pton.c: Fix MSVC run-time check failure#387
MarcelRaad wants to merge 1 commit intocurl:masterfrom
MarcelRaad:patch-2

Conversation

@MarcelRaad
Copy link
Member

Visual Studio complains with a message box at run-time:
"Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data.
If this was intentional, you should mask the source of the cast with the appropriate bitmask.
For example:
char c = (i & 0xFF);
Changing the code in this way will not affect the quality of the resulting optimized code."

This is because only 'val' is cast to unsigned char, so the "& 0xff" has no effect.

Visual Studio complains with a message box:
"Run-Time Check Failure #1 - A cast to a smaller data type has caused
a loss of data.
If this was intentional, you should mask the source of the cast with the
appropriate bitmask.
For example:  
char c = (i & 0xFF);
Changing the code in this way will not affect the quality of the resulting
optimized code."

This is because only 'val' is cast to unsigned char, so the "& 0xff" has
no effect.
@bagder bagder closed this in 618dfd6 Aug 19, 2015
@MarcelRaad MarcelRaad deleted the patch-2 branch August 19, 2015 07:34
jgsogo pushed a commit to jgsogo/curl that referenced this pull request Oct 19, 2015
Visual Studio complains with a message box:

"Run-Time Check Failure whoshuu#1 - A cast to a smaller data type has caused a
loss of data.  If this was intentional, you should mask the source of
the cast with the appropriate bitmask.

For example:
char c = (i & 0xFF);

Changing the code in this way will not affect the quality of the
resulting optimized code."

This is because only 'val' is cast to unsigned char, so the "& 0xff" has
no effect.

Closes curl#387
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant