*new* check_macros: find macro precedence bugs
[smatch.git] / validation / sm_null_deref2.c
blob258c4bceb4b4496d1d64978acd2d80deef397a73
1 int *ptr;
2 int x, y, z;
3 void frob(void) {
4 if ((y && !ptr) || z)
5 return;
6 if (ptr) {
7 /* in the current version of smatch this erases
8 the old implications. Later version should
9 fix this. --Dec 2 2009 */
10 x = *ptr;
12 if (!y && ptr)
13 *ptr = 0; // smatch used to print an error here.
14 if (!y)
15 *ptr = 1;
18 * check-name: Dereferencing Undefined
19 * check-command: smatch sm_null_deref2.c
21 * check-output-start
22 sm_null_deref2.c +15 frob(12) error: we previously assumed 'ptr' could be null.
23 * check-output-end