* asan.c (pass_sanopt::execute): Handle IFN_UBSAN_OBJECT_SIZE.
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / object-size-4.c
blob8b95ec9c800e9e1f2aeb19256e47946d414695f5
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
3 /* { dg-options "-fsanitize=object-size" } */
5 /* Test that we instrument flexible array members. */
7 struct T { int l; int a[]; };
8 struct U { int l; int a[0]; };
10 int
11 main (void)
13 volatile int i;
14 struct T *t = (struct T *) __builtin_calloc (sizeof (struct T)
15 + sizeof (int), 1);
16 i = t->a[1];
18 struct U *u = (struct U *) __builtin_calloc (sizeof (struct U)
19 + sizeof (int), 1);
20 i = u->a[1];
21 return 0;
24 /* { dg-output "load of address \[^\n\r]* with insufficient space for an object of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
25 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
26 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
27 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */
28 /* { dg-output "\[^\n\r]*load of address \[^\n\r]* with insufficient space for an object of type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
29 /* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
30 /* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
31 /* { dg-output "\[^\n\r]*\\^\[^\n\r]*(\n|\r\n|\r)" } */