Skip to content

build: enable -Wimplicit-int-enum-cast compiler warning, fix issues - #20990

Closed
vszakats wants to merge 4 commits into
curl:masterfrom
vszakats:enumcast
Closed

vszakats wants to merge 4 commits into
curl:masterfrom
vszakats:enumcast

Conversation

@vszakats

@vszakats vszakats commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

Offered by clang 21+.

@vszakats vszakats added the build label Mar 18, 2026
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
@github-actions github-actions Bot added the tests label Mar 18, 2026
@vszakats vszakats changed the title build: enable -Wimplicit-int-enum-cast compiler warning, fix issue build: enable -Wimplicit-int-enum-cast compiler warning, fix issues Mar 18, 2026
@vszakats vszakats closed this in 59405ff Mar 19, 2026
@vszakats
vszakats deleted the enumcast branch March 19, 2026 10:18
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
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
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant