Skip to content

error: -Wshorten-64-to-32 with openssl3 quic and Windows 64-bit #12861

Description

@dtretyakov

I did this

Compile curl for Windows x86_64 with openssl3 and nghttp3:

vquic/curl_osslq.c:1081:30: error: implicit conversion loses integer precision: 'curl_socket_t' (aka 'unsigned long long') to 'int' [-Werror,-Wshorten-64-to-32]
 1081 |   bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE);
      |         ~~~~~~~~~~~~~ ~~~~~~~^~~~~~
1 error generated.

Configuration:

  Host setup:       x86_64-w64-mingw32
  Install prefix:   /data/curl
  Compiler:         x86_64-w64-mingw32-clang
   CFLAGS:          -DCARES_STATICLIB -DCURL_STATICLIB -DNGHTTP2_STATICLIB -DNGHTTP3_STATICLIB -DNGTCP2_STATICLIB -Qunused-arguments -O2 -pedantic -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wsign-compare -Wno-multichar -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wcast-align -Wno-system-headers -Wshorten-64-to-32 -Wunused -Waddress -Wattributes -Wbad-function-cast -Wconversion -Wdiv-by-zero -Wformat-security -Wempty-body -Wmissing-field-initializers -Wmissing-noreturn -Wold-style-definition -Wredundant-decls -Wtype-limits -Wunreachable-code -Wunused-parameter -Wignored-qualifiers -Wvla -Wsign-conversion -Wno-error=sign-conversion -Wshift-sign-overflow -Wlanguage-extension-token -Wformat=2 -Wenum-conversion -Wsometimes-uninitialized -Wheader-guard -Wunused-const-variable -Wpragmas -Wunreachable-code-break -Wdouble-promotion -Wcomma -Wassign-enum -Wextra-semi-stmt -Wimplicit-fallthrough -Wno-pointer-bool-conversion
   CPPFLAGS:        -isystem /opt/llvm-mingw/generic-w64-mingw32/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include -isystem /data/curl/include
   LDFLAGS:         -L/opt/llvm-mingw/x86_64-w64-mingw32/lib -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib64 -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib -L/data/curl/lib
   LIBS:            -lcares -lws2_32 -liphlpapi -lnghttp3 -lnghttp2 -lidn2 -lunistring -lssh2 -lssh2 -lws2_32 -lssl -lcrypto -lws2_32 -lssl -lcrypto -lssl -lcrypto -lws2_32 -lgdi32 -lcrypt32 -lz -lpsl -lbcrypt -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lws2_32 -lgdi32 -lcrypt32 -lgdi32 -lzstd -lzstd -lbrotlidec -lbrotlidec -lbrotlicommon -lz -lws2_32

Reference to the called function BIO *BIO_new_dgram(int fd, int close_flag).

I expected the following

No compilation error. As a worakround it's possible to disable convertion check -Wno-error=shorten-64-to-32

curl/libcurl version

curl 8.6.0

operating system

ubuntu 20.04, x86_64

Activity

  1. dtretyakov commented on Feb 5, 2024

    @dtretyakov
    Author

    To reproduce it's possible to uncomment the following line in build script:
    https://github.com/stunnel/static-curl/blob/4e5e8b69d368a1aeea5f039528745b1207034c38/curl-static-win.sh#L619

    and then run the following: ARCH=x86_64 CURL_VERSION=8.6.0 TLS_LIB=openssl sh curl-static-win.sh

  2. icing commented on Feb 5, 2024

    @icing
    Contributor

    Thanks for the report. That is indeed an unfortunate mix of OpenSSL's definition of a socket handle and Microsoft's choice of defining their SOCKET type on 64 bit platforms. See also this stackoverflow issue.

    I'll add code that checks the SOCKET value before casting it to int explicitly. This will probably never fail, since Microsoft is unlikely to ever use the upper 32 bits and break many OpenSSL applications. But stranger things have happened.

  3. self-assigned this
    on Feb 5, 2024
  4. icing commented on Feb 5, 2024

    @icing
    Contributor

    Added #12865 for this.

  5. added a commit that references this issue on Feb 5, 2024
  6. added a commit that references this issue on Feb 5, 2024
    d6825df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions