Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/c-c++-common/ubsan/nonnull-3.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* { dg-do run } */ /* { dg-shouldfail "ubsan" } */ /* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */ int q, r; void *a, *b, *c = (void *) &q, *d, *e, *f = (void *) &q, *g, *h; __attribute__((returns_nonnull, nonnull (1, 3))) void * foo (void *p, void *q, void *r) { a = p; b = r; return q; } int bar (const void *a, const void *b) { int c = *(const int *) a; int d = *(const int *) b; return c - d; } int main () { asm volatile ("" : : : "memory"); d = foo (c, (void *) &r, c); e = foo (e, c, f); g = foo (c, f, g); __builtin_memset (d, '\0', q); return 0; } /* { dg-output "\.c:30:\[0-9]*:\[^\n\r]*null pointer passed as argument 1, which is declared to never be null" } */