Comment 4 for bug 1641612

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

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