New compilation warnings with GCC 6 (-Wshift-negative-value, -Wdeprecated-declarations, -Wnonnull-compare, -Wc+11-compat, -Wmisleading-indentation)

Bug #1641612 reported by Laurynas Biveinis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Fix Released
High
Laurynas Biveinis
5.6
Fix Released
High
Laurynas Biveinis
5.7
Fix Released
High
Laurynas Biveinis
Percona XtraBackup moved to https://jira.percona.com/projects/PXB
Status tracked in 2.4
2.3
Fix Released
High
Sergei Glushchenko
2.4
Fix Released
High
Sergei Glushchenko

Bug Description

On 5.5 trunk:

[ 7%] Building C object extra/CMakeFiles/innochecksum.dir/innochecksum.c.o
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/extra/innochecksum.c: In function ‘display_format_info’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/extra/innochecksum.c:60:8: error: left shift of negative value [-Werror=shift-negative-value]
 ((~(~0 << (DICT_TF_BITS - DICT_TF_FORMAT_SHIFT))) << DICT_TF_FORMAT_SHIFT)
        ^
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/extra/innochecksum.c:213:28: note: in expansion of macro ‘DICT_TF_FORMAT_MASK’
     ulint format = flags & DICT_TF_FORMAT_MASK >> DICT_TF_FORMAT_SHIFT;
                            ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
extra/CMakeFiles/innochecksum.dir/build.make:62: recipe for target 'extra/CMakeFiles/innochecksum.dir/innochecksum.c.o' failed
make[2]: *** [extra/CMakeFiles/innochecksum.dir/innochecksum.c.o] Error 1
make[2]: Target 'extra/CMakeFiles/innochecksum.dir/build' not remade because of errors.
CMakeFiles/Makefile2:3539: recipe for target 'extra/CMakeFiles/innochecksum.dir/all' failed
make[1]: *** [extra/CMakeFiles/innochecksum.dir/all] Error 2

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Re: New compilation warnings with GCC 6 (-Wshift-negative-value, -Wdeprecated-declarations)

/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/mysys/my_lib.c: In function ‘my_dir’:
/mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/mysys/my_lib.c:140:3: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
   while (!(READDIR(dirp,(struct dirent*) dirent_tmp,dp)))
   ^~~~~
In file included from /usr/include/features.h:364:0,
                 from /usr/include/pthread.h:21,
                 from /mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/include/my_global.h:274,
                 from /mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/mysys/mysys_priv.h:16,
                 from /mnt/workspace/percona-server-5.5-trunk/BUILD_TYPE/debug/Host/ubuntu-yakkety-64bit/mysys/my_lib.c:19:
/usr/include/dirent.h:189:12: note: declared here
 extern int __REDIRECT (readdir_r,
            ^

summary: - New compilation warnings with GCC 6 (-Wshift-negative-value)
+ New compilation warnings with GCC 6 (-Wshift-negative-value,
+ -Wdeprecated-declarations)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

In file included from /home/laurynas/mysql-server/storage/innobase/include/page0page.h:37:0,
                 from /home/laurynas/mysql-server/storage/innobase/include/page0cur.h:32,
                 from /home/laurynas/mysql-server/storage/innobase/include/btr0btr.h:33,
                 from /home/laurynas/mysql-server/storage/innobase/btr/btr0btr.c:26:
/home/laurynas/mysql-server/storage/innobase/include/fsp0fsp.ic: In function 'fsp_flags_get_page_size':
/home/laurynas/mysql-server/storage/innobase/include/fsp0fsp.h:45:10: warning: left shift of negative value [-Wshift-negative-value]
   ((~(~0 << FSP_FLAGS_WIDTH_PAGE_SSIZE)) \
          ^
/home/laurynas/mysql-server/storage/innobase/include/fsp0fsp.h:49:13: note: in expansion of macro 'FSP_FLAGS_MASK_PAGE_SSIZE'
   ((flags & FSP_FLAGS_MASK_PAGE_SSIZE) \
             ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/laurynas/mysql-server/storage/innobase/include/fsp0fsp.ic:59:16: note: in expansion of macro 'FSP_FLAGS_GET_PAGE_SSIZE'
  ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
                ^~~~~~~~~~~~~~~~~~~~~~~~

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Re: New compilation warnings with GCC 6 (-Wshift-negative-value, -Wdeprecated-declarations, -Wnonnull-compare)

In file included from /home/laurynas/mysql-server/storage/innobase/include/btr0btr.h:29:0,
                 from /home/laurynas/mysql-server/storage/innobase/btr/btr0btr.c:26:
/home/laurynas/mysql-server/storage/innobase/btr/btr0btr.c: In function 'dict_index_is_ibuf':
/home/laurynas/mysql-server/storage/innobase/include/ut0dbg.h:37:42: warning: nonnull argument 'index' compared to NULL [-Wnonnull-compare]
 # define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
                                          ^~~~~~~~~~~~~~~~
/home/laurynas/mysql-server/storage/innobase/include/univ.i:459:54: note: in definition of macro 'UNIV_EXPECT'
 # define UNIV_EXPECT(expr,constant) __builtin_expect(expr, constant)
                                                      ^~~~
/home/laurynas/mysql-server/storage/innobase/include/ut0dbg.h:37:28: note: in expansion of macro 'UNIV_UNLIKELY'
 # define UT_DBG_FAIL(EXPR) UNIV_UNLIKELY(!((ulint)(EXPR)))
                            ^~~~~~~~~~~~~
/home/laurynas/mysql-server/storage/innobase/include/ut0dbg.h:64:6: note: in expansion of macro 'UT_DBG_FAIL'
  if (UT_DBG_FAIL(EXPR)) { \
      ^~~~~~~~~~~
/home/laurynas/mysql-server/storage/innobase/include/ut0dbg.h:79:21: note: in expansion of macro 'ut_a'
 #define ut_ad(EXPR) ut_a(EXPR)
                     ^~~~
/home/laurynas/mysql-server/storage/innobase/include/dict0dict.ic:279:2: note: in expansion of macro 'ut_ad'
  ut_ad(index);
  ^~~~~

summary: New compilation warnings with GCC 6 (-Wshift-negative-value,
- -Wdeprecated-declarations)
+ -Wdeprecated-declarations, -Wnonnull-compare)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

For InnoDB -Wnonnull-compare, backport

commit 7b899ac00c5d6a18b5b8eda661885f6f1afc502a
Author: Marko Makela <email address hidden>
Date: Wed Oct 8 10:31:13 2014 +0300

    Bug#19632776 Code gets incorrectly optimized away by gcc

    As reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=764220
    it is possible that gcc incorrectly optimizes away some code
    when a function that takes a pointer or reference as a parameter
    is declared as attribute((const)) or attribute((pure)).

    The function affected was page_zip_rec_needs_ext().

    As a preventive measure, we will remove the potentially problematic
    attributes from all functions that take pointers or references that
    they are dereferencing. Functions that perform pointer arithmetics
    without dereferencing the pointers should be safe: page_offset() is
    an example.

    While we are at it, remove also some attribute((nonnull)).
    This attribute is dangerous, because it does not always generate
    a warning when NULL may be passed, but it may optimize away code
    for handling the NULL case. We wanted this attribute for the sake
    of the warnings, not for the optimizations.

    rb#6940 approved by Vasil Dimov and Jimmy Yang

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

/home/laurynas/mysql-server/sql/partition_info.cc: In member function 'partition_info* partition_info::get_clone(bool)':
/home/laurynas/mysql-server/sql/partition_info.cc:36:3: warning: nonnull argument 'this' compared to NULL [-Wnonnull-compare]
   if (!this)
   ^~

Backport

commit 33c2404b397e1077daaf0ef0ff9edba445430f5f
Author: Vasil Dimov <email address hidden>
Date: Wed Jan 21 10:33:58 2015 +0200

    Fix Bug#20380977 COMPILER WARNINGS IN MYSQL-5.6

    Remove unsued symbols and resolve other compiler warnings accordingly

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

For 5.6, HandlerSocket must be compiled with -std=gnu++98 to avoid std::auto_ptr deprecation warnings. For TokuDB, https://tokutek.atlassian.net/browse/FT-704 should be fixed at least to the point of resolving the new -Wnonnull-compare warnings.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

For 5.7, TokuDB must be compiled with -std=c++11.

summary: New compilation warnings with GCC 6 (-Wshift-negative-value,
- -Wdeprecated-declarations, -Wnonnull-compare)
+ -Wdeprecated-declarations, -Wnonnull-compare, -Wc+11-compat)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Re: New compilation warnings with GCC 6 (-Wshift-negative-value, -Wdeprecated-declarations, -Wnonnull-compare, -Wc+11-compat)

5.7 also causes -Wc++11-compat warnings not seen in lower versions:

In file included from /home/laurynas/mysql-server/storage/innobase/include/fts0priv.h:643:0,
                 from /home/laurynas/mysql-server/storage/innobase/dict/dict0crea.cc:48:
/home/laurynas/mysql-server/storage/innobase/include/fts0priv.ic:56:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
    return(sprintf(str, "%016"PRIu64, id)););
                        ^
/home/laurynas/mysql-server/storage/innobase/include/fts0priv.ic:69:23: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
   return(sprintf(str, "%016"PRIu64, id));
                       ^

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

/home/laurynas/mysql-server/sql/sql_update.cc: In function 'bool mysql_update(THD*, List<Item>&, List<Item>&, ha_rows, enum_duplicates, ha_rows*, ha_rows*)':
/home/laurynas/mysql-server/sql/sql_update.cc:814:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
       if (fill_record_n_invoke_before_triggers(thd, fields, values,
       ^~
/home/laurynas/mysql-server/sql/sql_update.cc:819:9: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
         found++;
         ^~~~~

summary: New compilation warnings with GCC 6 (-Wshift-negative-value,
- -Wdeprecated-declarations, -Wnonnull-compare, -Wc+11-compat)
+ -Wdeprecated-declarations, -Wnonnull-compare, -Wc+11-compat,
+ -Wmisleading-indentation)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

See also bug 1644183

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

For -Wnonnull-compare, this is partially upstream http://bugs.mysql.com/bug.php?id=83421

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PXB-487

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-1030

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.