Bug #87956 row0sel.cc:5178:32 error: ISO C++ forbids comparison between pointer and intege
Submitted: 3 Oct 2017 16:12 Modified: 5 Oct 2017 13:15
Reporter: Melanie Blower Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.7.19 OS:Red Hat
Assigned to: CPU Architecture:Any

[3 Oct 2017 16:12] Melanie Blower
Description:
Hello, I work at Intel on the Intel C++ compiler and we compile MySQL with various compilers including gcc and clang. We are finding an error reported on this line. The field is treated as though it were Boolean, but the type is int*. Will you please correct the usage?
Thanks and regards

Here's the report from gcc7,
.../mblower/_test/mysql-5.7.19/storage/innobase/row/row0sel.cc: In function ‘dberr_t row_search_mvcc(unsigned char*, page_cur_mode_t, row_prebuilt_t*, ulint, ulint)’:
/export/ics1/mblower/_test/mysql-5.7.19/storage/innobase/row/row0sel.cc:5178:32  error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
       && prebuilt->idx_cond == false && end_loop >= 100) {
                                ^~~~~
-bash-4.2$ which gcc
.../gcc/7.2.0/rhel70/efi2/bin/gcc

How to repeat:
cd .../_test/mysql-5.7.19/storage/innobase

Copied from the log file from building the package, this is the compile line which fails:

g++  -DCOMPILER_HINTS -DHAVE_CONFIG_H -DHAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE=1 -DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1 -DHAVE_IB_GCC_ATOMIC_COMPARE_EXCHANGE=1 -DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1 -DHAVE_IB_GCC_SYNC_SYNCHRONISE=1 -DHAVE_IB_LINUX_FUTEX=1 -DHAVE_LIBEVENT1 -DHAVE_LZ4=1 -DHAVE_NANOSLEEP=1 -DHAVE_SCHED_GETCPU=1 -DLINUX_NATIVE_AIO=1 -DMUTEX_EVENT -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -O2 -g -DNDEBUG -DDBUG_OFF -I.../_test/mysql-5.7.19/include -I.../_test/mysql-5.7.19/extra/rapidjson/include -I.../_test/mysql-5.7.19/libbinlogevents/include -I.../_test/mysql-5.7.19/libbinlogevents/export -I.../_test/mysql-5.7.19/extra/lz4 -I.../_test/mysql-5.7.19/storage/innobase/include -I.../_test/mysql-5.7.19/storage/innobase/handler -I.../_test/mysql-5.7.19/sql -I.../_test/mysql-5.7.19/sql/auth -I/.../_test/mysql-5.7.19/regex -I.../_test/mysql-5.7.19/extra/yassl/include -I.../_test/mysql-5.7.19/extra/yassl/taocrypt/include -I.../_test/mysql-5.7.19/zlib    -DUNIV_LINUX -D_GNU_SOURCE=1 -c .../_test/mysql-5.7.19/storage/innobase/row/row0sel.cc

Suggested fix:
Compare == NULL rather than == false
[4 Oct 2017 7:45] MySQL Verification Team
Hello Melanie Blower,

Thank you for the report and feedback!

Thanks,
Umesh
[4 Oct 2017 10:26] Tor Didriksen
You get this warning because gcc7 defaults to -std=C++14 which is *not*
supported for Mysql5.7

cmake/build_configurations/compiler_options.cmake contains:

    # GCC 6 has C++14 as default, set it explicitly to the old default.
    EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
                    OUTPUT_VARIABLE GXX_VERSION)
    IF(GXX_VERSION VERSION_EQUAL 6.0 OR GXX_VERSION VERSION_GREATER 6.0)
      SET(COMMON_CXX_FLAGS             "${COMMON_CXX_FLAGS} -std=gnu++03")
    ENDIF()

Use this, and your warning disappears.

In general you can not expect older/GA versions of MySQL to have a clean
build with new compilers. For the current development versions we *do* fix
build problems (currently working with warnings from gcc8) We occasionally
backport such fixes to GA versions.
[5 Oct 2017 13:15] Paul DuBois
Posted by developer:
 
Fixed in 5.7.21, 8.0.4, 9.0.0.

Code cleanup. No changelog entry needed.