gvariant tests: workaround libc/compiler "issue"
authorRyan Lortie <desrt@desrt.ca>
Tue, 24 Jun 2014 14:40:30 +0000 (10:40 -0400)
committerRyan Lortie <desrt@desrt.ca>
Tue, 24 Jun 2014 18:18:29 +0000 (14:18 -0400)
commitf727c820b823178285d90b3f033f7d2a4d3cdf9f
treee8d0b5ec2855c22cb8bf0f317769cfdbc9a7ac69
parentcf9b162e0d0defaff2ad5c85aeaf7af0899ad22f
gvariant tests: workaround libc/compiler "issue"

memcmp() is declared by glibc as follows:

  /* Compare N bytes of S1 and S2.  */
  extern int memcmp (const void *__s1, const void *__s2, size_t __n)
       __THROW __attribute_pure__ __nonnull ((1, 2));

despite the fact that it is valid to call it with a null pointer if the
size is zero.

gcc 4.9.0 contains a new optimisation that sees that we pass a pointer
to this function and concludes that it certainly must not be null,
removing a later check and thereby causing a crash.

We protect the invocation of memcmp() with a condition to prevent gcc
from making this false assumption (arguably under wrong advice from
glibc).
glib/tests/gvariant.c