gcc/testsuite/c-c++-common/analyzer/pr96651-1.c
raw| 1 | #include <stdlib.h> |
| 2 | #include <string.h> |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | static int a; |
| 6 | |
| 7 | int main(void) |
| 8 | { |
| 9 | char *src = NULL; |
| 10 | char buf[128]; |
| 11 | |
| 12 | /* "a" can't have been touched yet, and thus |
| 13 | is implicitly zero. */ |
| 14 | switch (a) { |
| 15 | case 1: |
| 16 | strcpy(buf, src); /* { dg-bogus "NULL" } */ |
| 17 | break; |
| 18 | case 0: |
| 19 | strcpy(buf, "hello"); |
| 20 | } |
| 21 | printf("%s\n", buf); |
| 22 | } |