diff --git a/lib/setopt.c b/lib/setopt.c
index 8639225ebb987a6f81c61aa7e47506a8ac49af2a..03c4efdbf1e587eaf840468ab533f1d5e28241be 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -195,7 +195,7 @@ static CURLcode protocol2num(char *str, curl_prot_t *val)
   if(!str)
     return CURLE_BAD_FUNCTION_ARGUMENT;
   else if(curl_strequal(str, "all")) {
-    *val = ~0;
+    *val = (curl_prot_t)~0;
     return CURLE_OK;
   }