/*
 * Compile with
gcc  -c `pkg-config --cflags glib-2.0` -Wincompatible-pointer-types steal.c
 * or, since -Wincompatible-pointer-types is the default, simply
gcc -c `pkg-config --cflags glib-2.0` steal.c
 */

#include <glib.h>

int
main (int argc, char **argv)
{
  int a = 1;
  int *b = &a;
  float *c;

  g_print ("a: %d, b: %p\n", a, b);

#undef g_steal_pointer
#define g_steal_pointer(pp) \
  (0 ? (*(pp)) : (g_steal_pointer) (pp))

  /* Incompatible pointer types, but no warning from gcc: */
  c = g_steal_pointer (&b);
  g_print ("a: %d, b: %p, c: %p, *c: %f\n", a, b, c, *c);

#undef g_steal_pointer
#define g_steal_pointer(pp) \
  ((__typeof__(*pp)) (g_steal_pointer) (pp))

  b = &a;
  /* Incompatible pointer types, and a warning from gcc: */
  c = g_steal_pointer (&b); /* line 33 */

  return 0;
}
