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
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:
g++:
clang++:
Possible solutions:
CURLOPT_SSLVERSIONin the same enumI expected the following
No compiler warning.
curl/libcurl version
curl master
operating system
Fedora Linux 39