Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35605

Compile error with gcc-15 (Return type from mysql_real_connect is not bool.)

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Incomplete
    • 11.4.4
    • N/A
    • Scripts & Clients
    • None
    • LibreELEC with gcc-15-20241117

    Description

      Return type from mysql_real_connect is not bool.

      /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ -DHAVE_CONFIG_H -DHAVE_DLOPEN -D_FILE_OFFSET_BITS=64 -Dmariadb_EXPORTS -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/libmariadb/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/.x86_64-libreelec-linux-gnu/libmariadb/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/wsrep-lib/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/wsrep-lib/wsrep-API/v26 -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/.x86_64-libreelec-linux-gnu/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/include/providers -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/mysys_ssl -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/zlib -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/.x86_64-libreelec-linux-gnu/zlib -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/sql -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/strings -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/extra/readline -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/.x86_64-libreelec-linux-gnu/client -march=x86-64-v3 -Wall -pipe  -O2 -fomit-frame-pointer -DNDEBUG  -DDBUG_OFF -std=gnu++11   -DHAVE_OPENSSL -DOPENSSL_API_COMPAT=0x10100000L -MD -MT client/CMakeFiles/mariadb.dir/mysql.cc.o -MF client/CMakeFiles/mariadb.dir/mysql.cc.o.d -o client/CMakeFiles/mariadb.dir/mysql.cc.o -c /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-11.4.4/client/mysql.cc
      ../client/mysql.cc: In function 'NCURSES_BOOL do_connect(MYSQL*, const char*, const char*, const char*, const char*, ulong)':
      ../client/mysql.cc:1529:28: error: invalid conversion from 'MYSQL*' {aka 'st_mysql*'} to 'NCURSES_BOOL' {aka 'int'} [-fpermissive]
       1529 |   return mysql_real_connect(mysql, host, user, password, database,
            |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |                            |
            |                            MYSQL* {aka st_mysql*}
       1530 |                             opt_mysql_port, opt_mysql_unix_port, flags);
            |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      

      Attachments

        Activity

          where does

          #define bool NCURSES_BOOL
          

          come from? mysql.cc is a C++ source file, bool is a native C++ type. Why it's defined to NCURSES_BOOL ?

          serg Sergei Golubchik added a comment - where does #define bool NCURSES_BOOL come from? mysql.cc is a C++ source file, bool is a native C++ type. Why it's defined to NCURSES_BOOL ?
          heitbaum Rudi Heitbaum added a comment -

          We found where ncurses is overriding bool.

          See

          The fix is to declare NCURSES_ENABLE_STDBOOL_H
          e.g.
          +AC_DEFINE([NCURSES_ENABLE_STDBOOL_H], [1], [Define to enable stdbool.h in ncurses])

          heitbaum Rudi Heitbaum added a comment - We found where ncurses is overriding bool. See https://github.com/htop-dev/htop/issues/1567#issuecomment-2528421111 https://github.com/Syllo/nvtop/pull/332#issuecomment-2527740914 The fix is to declare NCURSES_ENABLE_STDBOOL_H e.g. +AC_DEFINE( [NCURSES_ENABLE_STDBOOL_H] , [1] , [Define to enable stdbool.h in ncurses] )

          curses.h (in my local installation, sys-libs/ncurses-6.4_p20240414) has

          #if defined(__cplusplus)	/* __cplusplus, etc. */
          /* use the C++ compiler's bool type */
          #define NCURSES_BOOL bool
          #else			/* c89, c99, etc. */
          #if NCURSES_ENABLE_STDBOOL_H
          #include <stdbool.h>
          /* use whatever the C compiler decides bool really is */
          #define NCURSES_BOOL bool
          #else
          /* there is no predefined bool - use our own */
          #undef bool
          #define bool NCURSES_BOOL
          #endif
          

          That is, in C++ it should always use bool, while in C it should only use bool if NCURSES_ENABLE_STDBOOL_H is defined, otherwise it uses NCURSES_BOOL.

          mysql.cc is C++. You seem to be using g++ to compile it. How comes __cplusplus is not defined? It shouldn't be possible. Or perhaps you have a strange or broken ncurses that doesn't check for __cplusplus ?

          serg Sergei Golubchik added a comment - curses.h (in my local installation, sys-libs/ncurses-6.4_p20240414 ) has #if defined(__cplusplus) /* __cplusplus, etc. */ /* use the C++ compiler's bool type */ #define NCURSES_BOOL bool #else /* c89, c99, etc. */ #if NCURSES_ENABLE_STDBOOL_H #include <stdbool.h> /* use whatever the C compiler decides bool really is */ #define NCURSES_BOOL bool #else /* there is no predefined bool - use our own */ #undef bool #define bool NCURSES_BOOL #endif That is, in C++ it should always use bool , while in C it should only use bool if NCURSES_ENABLE_STDBOOL_H is defined, otherwise it uses NCURSES_BOOL . mysql.cc is C++. You seem to be using g++ to compile it. How comes __cplusplus is not defined? It shouldn't be possible. Or perhaps you have a strange or broken ncurses that doesn't check for __cplusplus ?
          heitbaum Rudi Heitbaum added a comment -

          You were correct. The issue is that ncurses - when cross compiled does not setup bool correctly.

          Compiling ncurses with

          --cache-file=config.cache

          cf_cv_builtin_bool=1
          cf_cv_header_stdbool_h=1

          fixes this issue without the need to set NCURSES_ENABLE_STDBOOL_H externally

          heitbaum Rudi Heitbaum added a comment - You were correct. The issue is that ncurses - when cross compiled does not setup bool correctly. Compiling ncurses with --cache-file=config.cache cf_cv_builtin_bool=1 cf_cv_header_stdbool_h=1 fixes this issue without the need to set NCURSES_ENABLE_STDBOOL_H externally

          I'm not sure I quite understand, so double-checking. Are you saying this should be closed as not a bug? (not mariadb bug, at least)

          serg Sergei Golubchik added a comment - I'm not sure I quite understand, so double-checking. Are you saying this should be closed as not a bug? (not mariadb bug, at least)

          People

            Unassigned Unassigned
            heitbaum Rudi Heitbaum
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.