gcc/testsuite/g++.dg/ubsan/null-8.C
raw| 1 | // PR c++/79572 |
| 2 | // { dg-do run } |
| 3 | // { dg-options "-fsanitize=null -std=c++14" } |
| 4 | // { dg-output "reference binding to null pointer of type 'const int'" } |
| 5 | |
| 6 | __attribute__((noinline, noclone)) |
| 7 | void |
| 8 | bar (int x) |
| 9 | { |
| 10 | asm volatile ("" : : "r" (x) : "memory"); |
| 11 | } |
| 12 | |
| 13 | void |
| 14 | foo (const int &iref) |
| 15 | { |
| 16 | if (&iref) |
| 17 | bar (iref); |
| 18 | else |
| 19 | bar (1); |
| 20 | } |
| 21 | |
| 22 | int |
| 23 | main () |
| 24 | { |
| 25 | foo (*((int*) __null)); |
| 26 | } |