Bug #75759 Remove __attribute__((nonnull)) from InnoDB
Submitted: 4 Feb 2015 8:25 Modified: 9 Apr 2015 17:03
Reporter: Vasil Dimov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.6 OS:Any
Assigned to: CPU Architecture:Any

[4 Feb 2015 8:25] Vasil Dimov
Description:
__attribute__((nonnull)) is forbidden by InnoDB coding guidelines, but there are leftovers from past times.

Some bits of code in InnoDB wrongly use that attribute and later use the parameter in a conditionals, checking if it is NULL, but the compiler knows that it is not NULL and could optimize those conditionals altogether, causing very hard to diagnose bugs.

Now, with clang 3.6 we even gets compiler warnings about those and it is time to remove them.

/usr/home/vd/mysql/storage/innobase/include/btr0btr.ic:204:8: error: nonnull parameter 'page' will
      evaluate to 'true' on first encounter [-Werror,-Wpointer-bool-conversion]
        ut_ad(page && mtr);
              ^~~~ ~~

How to repeat:
Try to compile with clang 3.6

Suggested fix:
s/__attribute__((nonnull))//
[9 Apr 2015 17:03] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.8.0 release, and here's the changelog entry:

"__attribute__((nonnull))" was removed from "InnoDB" code. The attribute
is no longer permitted by "InnoDB" coding guidelines.