Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURLOPT_SSLVERSION: C++20 deprecation warning when values of two enums are combined #13510

Closed
mkauf opened this issue Apr 30, 2024 · 1 comment

Comments

@mkauf
Copy link
Contributor

mkauf commented Apr 30, 2024

I did this

C++20 compilers emit a deprecation warning if values from two different enums are combined with a bitwise operation. This may happen when using CURLOPT_SSLVERSION.

Example program:

#include <curl/curl.h>

int main(void)
{
  CURL *curl = curl_easy_init();
  curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2);
  return 0;
}

g++:

$ g++ -std=c++20 -Wall -Icurl-inst/include -Lcurl-inst/lib simplessl.cpp  -lcurl
In file included from simplessl.cpp:1:
simplessl.cpp: In function ‘int main()’:
simplessl.cpp:6:70: warning: bitwise operation between different enumeration types ‘<unnamed enum>’ and ‘<unnamed enum>’ is deprecated [-Wdeprecated-enum-enum-conversion]
    6 |   curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2);
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curl-inst/include/curl/curl.h:3244:72: note: in definition of macro ‘curl_easy_setopt’
 3244 | #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
      |                                                                        ^~~~~

clang++:

$ clang++ -std=c++20 -Wall -Icurl-inst/include -Lcurl-inst/lib simplessl.cpp  -lcurl
simplessl.cpp:6:70: warning: bitwise operation between different enumeration types ('(unnamed enum at curl-inst/include/curl/curl.h:2321:1)' and '(unnamed enum at curl-inst/include/curl/curl.h:2334:1)') is deprecated [-Wdeprecated-anon-enum-enum-conversion]
    6 |   curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2);
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
curl-inst/include/curl/curl.h:3244:72: note: expanded from macro 'curl_easy_setopt'
 3244 | #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
      |                                                                        ^~~~~
1 warning generated.

Possible solutions:

I expected the following

No compiler warning.

curl/libcurl version

curl master

operating system

Fedora Linux 39

@mkauf mkauf changed the title CURLOPT_SSLVERSION: C++23 deprecation warning when values of two enums are used CURLOPT_SSLVERSION: C++23 deprecation warning when values of two enums are combined Apr 30, 2024
bagder added a commit that referenced this issue Apr 30, 2024
C++23 compilers emit a deprecation warning if values from two different
enums are combined with a bitwise operation the way the
CURL_SSLVERSION_* values were previously created.

Reported-by: Michael Kaufmann
Fixes #13510
@mkauf mkauf changed the title CURLOPT_SSLVERSION: C++23 deprecation warning when values of two enums are combined CURLOPT_SSLVERSION: C++20 deprecation warning when values of two enums are combined May 2, 2024
@mkauf
Copy link
Contributor Author

mkauf commented May 2, 2024

I have updated the issue, the warning is also generated in C++20 mode (but not in C++17 mode).

@bagder bagder closed this as completed in eb06c1b May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant