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

clang 6 builds fail

    XMLWordPrintable

Details

    Description

      As reported to me by a FreeBSD committer (Dimitry Andric):

      When building with clang 6, which defaults to -std=gnu++14 for C++ mode,
      databases/mariadb102-server fails to build, with the following errors:

      [48%] Building CXX object storage/connect/CMakeFiles/connect.dir/tabjson.cpp.o
      cd
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect
      && /usr/bin/c++  -DFORCE_INIT_OF_VARS -DGZ_SUPPORT -DHAVE_CONFIG_H
      -DHUGE_SUPPORT -DLIBXML2_SUPPORT -DLINUX -DMARIADB -DMYSQL_DYNAMIC_PLUGIN
      -DNOCRYPT -DODBC_SUPPORT -DUBUNTU -DUNIX -DVCT_SUPPORT -DXMAP -DZIP_SUPPORT
      -Dconnect_EXPORTS
      -I/wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/include
      -I/wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/sql
      -I/wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/pcre
      -I/usr/local/include -I/usr/local/include/libxml2 -O2 -pipe -march=haswell
      -fstack-protector -isystem /usr/local/include -fno-strict-aliasing  -isystem
      /usr/local/include -Wl,-z,relro,-z,now -fstack-protector
      --param=ssp-buffer-size=4 -DWITH_INNODB_DISALLOW_WRITES -fno-rtti -Wall
      -Wmissing-declarations -Wno-unused-function -Wno-unused-variable
      -Wno-unused-value -Wno-parentheses -Wno-strict-aliasing
      -Wno-implicit-fallthrough -fpermissive -fexceptions -fPIC  -O2 -pipe
      -march=haswell -fstack-protector -isystem /usr/local/include
      -fno-strict-aliasing  -isystem /usr/local/include -D_FORTIFY_SOURCE=2
      -DDBUG_OFF -fPIC -o CMakeFiles/connect.dir/tabjson.cpp.o -c
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp
      c++: warning: -Wl,-z,relro,-z,now: 'linker' input unused
      [-Wunused-command-line-argument]
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:198:10:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                      return NULL;
                             ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:246:11:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                              return NULL;
                                     ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:253:12:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                                      return NULL;
                                             ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:272:12:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                                      return NULL;
                                             ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:279:12:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                                      return NULL;
                                             ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:288:12:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                                      return NULL;
                                             ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      /wrkdirs/usr/ports/databases/mariadb102-server/work/mariadb-10.2.14/storage/connect/tabjson.cpp:307:11:
      error: cannot initialize return object of type 'int' with an rvalue of type
      'nullptr_t'
                              return NULL;
                                     ^~~~
      /usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
      #define NULL    nullptr
                      ^~~~~~~
      7 errors generated.
      

      In this case, NULL is not suitable as a return value for a function returning
      int. (Before C++11, NULL was usually defined as plain zero, which is why this
      bad code used to compile.)

      Fix it by returning integer zero instead, like in most other places in the same
      function.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              spil Bernard Spil
              Votes:
              1 Vote for this issue
              Watchers:
              3 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.