xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_167.c (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*	$NetBSD: msg_167.c,v 1.3 2021/01/31 11:12:07 rillig Exp $	*/
2 # 3 "msg_167.c"
3 
4 // Test for message: array subscript cannot be negative: %ld [167]
5 
6 void
7 example(int *ptr)
8 {
9 	int arr[6];
10 
11 	arr[-3] = 13;		/* expect: 167 */
12 
13 	/*
14 	 * Since the pointer may have been initialized with "arr + 3",
15 	 * subtracting from its address is allowed.
16 	 */
17 	ptr[-3] = 13;
18 }
19