view gcc/testsuite/c-c++-common/asan/bitfield-1.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* Check that Asan correctly instruments bitfields with non-round size.  */

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

struct A
{
  char base;
  int : 4;
  long x : 7;
};

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" } */