Repository navigation
Conversation
vszakats
marked this pull request as draft
January 1, 2026 15:39
BIT() a bitfield
BIT() a bitfieldBIT() a bitfield
vszakats
marked this pull request as ready for review
January 2, 2026 03:01
BIT() a bitfieldBIT() a bitfield with Visual Studio
vszakats
force-pushed
the
msvcbit
branch
9 times, most recently
from
January 15, 2026 12:20
a7f1a2a to
daddef4
Compare
..\..\lib\url.c(1368): warning C4242: '=' : conversion from 'bit' to 'unsigned char', possible loss of data https://ci.appveyor.com/project/curlorg/curl/builds/53311748/job/jdbaakbfqagm9149
/home/runner/work/curl/curl/lib/ftp.c:2064:30: error: conversion from ‘bit’ {aka ‘unsigned int’} to ‘unsigned char:1’ may change value [-Werror=conversion]
2064 | data->set.include_header = save;
| ^~~~
https://github.com/curl/curl/actions/runs/20649020582/job/59290673546?pr=20142
…asses without cast)
…penssl passes without cast)" This reverts commit bd4447b.
src\tool_cb_wrt.c(247,23): error C2220: the following warning is treated as an error src\tool_cb_wrt.c(247,23): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data src\tool_operate.c(1141,32): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data src\tool_operate.c(1142,28): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data src\tool_operate.c(2148,32): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data src\tool_operate.c(2149,28): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data https://ci.appveyor.com/project/curlorg/curl/builds/53311787/job/yfpcwxuuyl2qq14v
This was referenced Oct 13, 2026
vszakats
added a commit
that referenced
this pull request
Oct 16, 2026
…ol type Setting the `CURLWS_NOAUTOPONG` flag via the `CURLOPT_WS_OPTIONS` `curl_easy_setopt()` API failed to enable this flag in libcurl builds using a compiler without a native C99 bool type. This in turn caused 2700, 2709, 2711, 2712 WebSocket tests to fail. The initial WebSocket code assigned `arg & CURLWS_RAW_MODE` to a bit-field, after casting the expression to `bool`. This worked because `CURLWS_RAW_MODE` equals 1. Later this line was cloned when adding support for `CURLWS_NOAUTOPONG`, but this new bit flag's value was 2. Casting it to `bool` and then assigning it to a bit-field worked as expected, as long as the bool type was the C99 one. On compilers without the C99 bool type, the interim cast did not work, and when assigning the value 2 to the bit-field, it ended up storing zero/false unconditionally. Such compilers are VS2012 and VS2010. For them, another trigger was a subsequent update that enabled bit-field support for MSVC compilers. Fix by replacing the `(bool)` cast with `!!`. Also for `CURLWS_RAW_MODE`, to not rely on the literal value of this macro, and to avoid reusing this pattern in future code. There were no other places in the codebase with this pattern. The rest use either `!!` or ternary expression for this type of conversion. Discovered while trying to enable tests for MSVC builds in AppVeyor CI, causing test failures with VS2012 and VS2010. Refs: https://en.cppreference.com/c/language/arithmetic_types#Boolean_type https://en.cppreference.com/c/language/conversion https://godbolt.org/z/3h5zMfePq Bug: #23306 (comment) Bug: #23306 (comment) Follow-up to 85c841c #20142 Follow-up to c0df01f #16744 Follow-up to 664249d #8995 Cherry-picked from #23306 Closes #23428
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.
Add casts to
bool, or usebittype in local variables, whereneccessary to avoid MSVC compiler warnings C4242.
Note: There may remain places needing the above updates, where not
tested in CI, and missed in manual review.
Also:
connect_onlyto bitfield to match itscounterpart in another struct.
bittype tocurl_bit.BIT()#20152.bittocurl_bit? [DONE, though maybe move it to separate post-PR, because it changes a few (=5) pre-existing lines and unrelated to this PR stricly speaking.]Also tried switching over
boolarguments tobit, to avoid casts.I expected it to work, but in practice it resulted in GCC warnings,
possibly where the bitfields ended up using different integer types
depending on how many of them were declared next to each other. That's
my guess at least.