summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/align-5.c
blob: b94e167bb67b8b701711955c1ef5b29d6b02ce22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* { dg-do compile } */
/* { dg-options "-fno-sanitize=null -fsanitize=alignment -O2" } */
/* Check that when optimizing if we know the alignment is right
   and we are not doing -fsanitize=null instrumentation we don't
   instrument the alignment check.  */

__attribute__((noinline, noclone)) int
foo (char *p)
{
  p = (char *) __builtin_assume_aligned (p, __alignof__(int));
  int *q = (int *) p;
  return *q;
}

/* { dg-final { scan-assembler-not "__ubsan_handle" } } */