Skip to content

Build warnings with Gcc8 #2560

Closed
Closed
@rikardfalkeborn

Description

@rikardfalkeborn

I did this

Built curl with Gcc 8.

$ ./buildconf
$ ./configure --enable-debug --enable-warnings --enable-werror CC=gcc
$ make

I expected the following

Successful build, instead I got this:

md5.c:489:5: error: cast between incompatible function types from ‘int (*)(MD5_CTX *)’ {aka ‘int (*)(struct MD5state_st *)’} to ‘void (*)(void *)’ [-Werror=cast-function-type]
     (HMAC_hinit_func) MD5_Init,           /* Hash initialization function. */
     ^
md5.c:490:5: error: cast between incompatible function types from ‘int (*)(MD5_CTX *, const void *, size_t)’ {aka ‘int (*)(struct MD5state_st *, const void *, long unsigned int)’} to ‘void (*)(void *, const unsigned char *, unsigned int)’ [-Werror=cast-function-type]
     (HMAC_hupdate_func) MD5_Update,       /* Hash update function. */
     ^
md5.c:491:5: error: cast between incompatible function types from ‘int (*)(unsigned char *, MD5_CTX *)’ {aka ‘int (*)(unsigned char *, struct MD5state_st *)’} to ‘void (*)(unsigned char *, void *)’ [-Werror=cast-function-type]
     (HMAC_hfinal_func) MD5_Final,         /* Hash computation end function. */
     ^
md5.c:500:5: error: cast between incompatible function types from ‘int (*)(MD5_CTX *)’ {aka ‘int (*)(struct MD5state_st *)’} to ‘void (*)(void *)’ [-Werror=cast-function-type]
     (Curl_MD5_init_func) MD5_Init,      /* Digest initialization function */
     ^
md5.c:501:5: error: cast between incompatible function types from ‘int (*)(MD5_CTX *, const void *, size_t)’ {aka ‘int (*)(struct MD5state_st *, const void *, long unsigned int)’} to ‘void (*)(void *, const unsigned char *, unsigned int)’ [-Werror=cast-function-type]
     (Curl_MD5_update_func) MD5_Update,  /* Digest update function */
     ^
md5.c:502:5: error: cast between incompatible function types from ‘int (*)(unsigned char *, MD5_CTX *)’ {aka ‘int (*)(unsigned char *, struct MD5state_st *)’} to ‘void (*)(unsigned char *, void *)’ [-Werror=cast-function-type]
     (Curl_MD5_final_func) MD5_Final,    /* Digest computation end function */
     ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:1558: libcurl_la-md5.lo] Error 1
http2.c: In function ‘http2_connisdead’:
http2.c:208:18: error: cast between incompatible function types from ‘recving’ {aka ‘int (*)(void)’} to ‘ssize_t (*)(struct connectdata *, int,  char *, size_t,  CURLcode *)’ {aka ‘long int (*)(struct connectdata *, int,  char *, long unsigned int,  enum <anonymous> *)’} [-Werror=cast-function-type]
         nread = ((Curl_recv *)httpc->recv_underlying)(
                  ^
http2.c: In function ‘send_callback’:
http2.c:368:14: error: cast between incompatible function types from ‘sending’ {aka ‘int (*)(void)’} to ‘ssize_t (*)(struct connectdata *, int,  const void *, size_t,  CURLcode *)’ {aka ‘long int (*)(struct connectdata *, int,  const void *, long unsigned int,  enum <anonymous> *)’} [-Werror=cast-function-type]
   written = ((Curl_send*)c->send_underlying)(conn, FIRSTSOCKET,
              ^
http2.c: In function ‘http2_recv’:
http2.c:1604:16: error: cast between incompatible function types from ‘recving’ {aka ‘int (*)(void)’} to ‘ssize_t (*)(struct connectdata *, int,  char *, size_t,  CURLcode *)’ {aka ‘long int (*)(struct connectdata *, int,  char *, long unsigned int,  enum <anonymous> *)’} [-Werror=cast-function-type]
       nread = ((Curl_recv *)httpc->recv_underlying)(
                ^
http2.c: In function ‘Curl_http2_switched’:
http2.c:2141:28: error: cast between incompatible function types from ‘ssize_t (*)(struct connectdata *, int,  char *, size_t,  CURLcode *)’ {aka ‘long int (*)(struct connectdata *, int,  char *, long unsigned int,  enum <anonymous> *)’} to ‘int (*)(void)’ [-Werror=cast-function-type]
   httpc->recv_underlying = (recving)conn->recv[FIRSTSOCKET];
                            ^
http2.c:2142:28: error: cast between incompatible function types from ‘ssize_t (*)(struct connectdata *, int,  const void *, size_t,  CURLcode *)’ {aka ‘long int (*)(struct connectdata *, int,  const void *, long unsigned int,  enum <anonymous> *)’} to ‘int (*)(void)’ [-Werror=cast-function-type]
   httpc->send_underlying = (sending)conn->send[FIRSTSOCKET];
                            ^
cc1: all warnings being treated as errors
make[2]: *** [Makefile:2874: libcurlu_la-http2.lo] Error 1
make[1]: *** [Makefile:746: all] Error 2
make: *** [Makefile:924: all-recursive] Error 1

This seems to be a new warning in Gcc 8 (https://gcc.gnu.org/gcc-8/changes.html)

-Wcast-function-type warns when a function pointer is cast to an incompatible function pointer. This warning is enabled by -Wextra.

curl/libcurl version

$ git rev-parse HEAD
c3d7db4ecb2f8a0b22bd7cdf54ef10c119ebcc48

operating system

Linux (Arch Linux)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions