view gcc/testsuite/c-c++-common/asan/bitfield-4.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
line wrap: on
line source

/* Check that Asan correctly instruments bitfields with round offset.  */

/* { dg-do run } */
/* { dg-shouldfail "asan" } */

struct A
{
  char base;
  int : 0;
  int x : 8;
};

int __attribute__ ((noinline, noclone))
f (void *p) {
  return ((struct A *)p)->x;
}

int
main ()
{
  char a = 0;
  return f (&a);
}

/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */