build: enable -Wimplicit-int-enum-cast compiler warning, fix issues#20990
Closed
vszakats wants to merge 4 commits intocurl:masterfrom
Closed
build: enable -Wimplicit-int-enum-cast compiler warning, fix issues#20990vszakats wants to merge 4 commits intocurl:masterfrom
-Wimplicit-int-enum-cast compiler warning, fix issues#20990vszakats wants to merge 4 commits intocurl:masterfrom
Conversation
D:/a/curl/curl/tests/libtest/cli_hx_download.c:181:56: error: implicit conversion from 'int' to enumeration type 'gnutls_protocol_t' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
181 | t->idx, gnutls_protocol_get_name(v));
| ~~~~~~~~~~~~~~~~~~~~~~~~ ^
1 error generated.
https://github.com/curl/curl/actions/runs/23271420660/job/67664836659?pr=20990
-Wimplicit-int-enum-cast compiler warning, fix issue-Wimplicit-int-enum-cast compiler warning, fix issues
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Mar 20, 2026
Fixing (seen in HTTPSRR builds with clang 21+):
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/_a64-linux-gnu-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:34:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-https-connect.c:681:28: error: implicit conversion from 'unsigned char' to enumeration type 'enum alpnid' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
681 | enum alpnid alpn = rr->alpns[i];
| ~~~~ ^~~~~~~~~~~~
1 error generated.
```
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/lib/asyn.h:29:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:20: error: array has incomplete element type 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: note: forward declaration of 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
2 errors generated.
```
```
lib/httpsrr.c:81:45: warning: incompatible pointer types passing 'enum alpnid[4]' to parameter of type 'unsigned char *' [-Wincompatible-pointer-types]
81 | result = httpsrr_decode_alpn(val, vlen, hi->alpns);
| ^~~~~~~~~
lib/httpsrr.c:35:52: note: passing argument to parameter 'alpns' here
35 | unsigned char *alpns)
| ^
```
Follow-up to 59405ff curl#20990
Follow-up to 0d4fdbf curl#16054
3 tasks
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Mar 21, 2026
Fixing (seen in HTTPSRR builds with clang 21+):
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/_a64-linux-gnu-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:34:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-https-connect.c:681:28: error: implicit conversion from 'unsigned char' to enumeration type 'enum alpnid' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
681 | enum alpnid alpn = rr->alpns[i];
| ~~~~ ^~~~~~~~~~~~
1 error generated.
```
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/lib/asyn.h:29:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:20: error: array has incomplete element type 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: note: forward declaration of 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
2 errors generated.
```
```
lib/httpsrr.c:81:45: warning: incompatible pointer types passing 'enum alpnid[4]' to parameter of type 'unsigned char *' [-Wincompatible-pointer-types]
81 | result = httpsrr_decode_alpn(val, vlen, hi->alpns);
| ^~~~~~~~~
lib/httpsrr.c:35:52: note: passing argument to parameter 'alpns' here
35 | unsigned char *alpns)
| ^
```
Follow-up to 59405ff curl#20990
Follow-up to 0d4fdbf curl#16054
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Mar 21, 2026
Fixing (seen in HTTPSRR builds with clang 21+):
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/_a64-linux-gnu-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:34:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-https-connect.c:681:28: error: implicit conversion from 'unsigned char' to enumeration type 'enum alpnid' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
681 | enum alpnid alpn = rr->alpns[i];
| ~~~~ ^~~~~~~~~~~~
1 error generated.
```
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/lib/asyn.h:29:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:20: error: array has incomplete element type 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: note: forward declaration of 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
2 errors generated.
```
```
lib/httpsrr.c:81:45: warning: incompatible pointer types passing 'enum alpnid[4]' to parameter of type 'unsigned char *' [-Wincompatible-pointer-types]
81 | result = httpsrr_decode_alpn(val, vlen, hi->alpns);
| ^~~~~~~~~
lib/httpsrr.c:35:52: note: passing argument to parameter 'alpns' here
35 | unsigned char *alpns)
| ^
```
Follow-up to 59405ff curl#20990
Follow-up to 0d4fdbf curl#16054
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Mar 21, 2026
Fixing (seen in HTTPSRR builds with clang 21+):
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/_a64-linux-gnu-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:34:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-https-connect.c:681:28: error: implicit conversion from 'unsigned char' to enumeration type 'enum alpnid' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
681 | enum alpnid alpn = rr->alpns[i];
| ~~~~ ^~~~~~~~~~~~
1 error generated.
```
```
In file included from /home/runner/work/curl-for-win/curl-for-win/curl/lib/asyn.h:29:
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:20: error: array has incomplete element type 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
/home/runner/work/curl-for-win/curl-for-win/curl/lib/httpsrr.h:52:8: note: forward declaration of 'enum alpnid'
52 | enum alpnid alpns[MAX_HTTPSRR_ALPNS]; /* keytag = 1 */
| ^
2 errors generated.
```
```
lib/httpsrr.c:81:45: warning: incompatible pointer types passing 'enum alpnid[4]' to parameter of type 'unsigned char *' [-Wincompatible-pointer-types]
81 | result = httpsrr_decode_alpn(val, vlen, hi->alpns);
| ^~~~~~~~~
lib/httpsrr.c:35:52: note: passing argument to parameter 'alpns' here
35 | unsigned char *alpns)
| ^
```
Follow-up to 59405ff curl#20990
Follow-up to 0d4fdbf curl#16054
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Mar 21, 2026
Fixing (seen in HTTPS-RR builds with clang 21+ in curl-for-win dev):
```
In file included from _a64-linux-gnu-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:34:
lib/cf-https-connect.c:681:28: error: implicit conversion from 'unsigned char' to enumeration type 'enum alpnid' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
681 | enum alpnid alpn = rr->alpns[i];
| ~~~~ ^~~~~~~~~~~~
```
Follow-up to 59405ff curl#20990
Follow-up to 0d4fdbf curl#16054
Cherry-picked from curl#21032
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.
Offered by clang 21+.