[MDEV-15768] clang 6 builds fail Created: 2018-04-03  Updated: 2018-07-09  Resolved: 2018-07-09

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.2.14
Fix Version/s: 10.2.16

Type: Bug Priority: Major
Reporter: Bernard Spil Assignee: Sergei Golubchik
Resolution: Fixed Votes: 1
Labels: None
Environment:

FreeBSD 12-HEAD amd64


Attachments: File patch-storage_connect_tabjson.cpp    
Issue Links:
Relates
relates to MDEV-9627 clang builds fail on i386 Closed

 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.



 Comments   
Comment by Bernard Spil [ 2018-04-05 ]

After clang/llvm was updated to 6.0 on FreeBSD 11-STABLE we can confirm that this is also an issue on 11.
This is 11.2 which is due to be released this quarter.

Comment by Sergei Golubchik [ 2018-07-09 ]

Already fixed here

Generated at Thu Feb 08 08:23:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.