msg_167.c revision 1.6 1 /* $NetBSD: msg_167.c,v 1.6 2024/03/27 19:28:20 rillig Exp $ */
2 # 3 "msg_167.c"
3
4 // Test for message: array subscript cannot be negative: %jd [167]
5
6 /* lint1-extra-flags: -X 351 */
7
8 void
9 example(int *ptr)
10 {
11 int arr[6];
12
13 /* expect+1: warning: array subscript cannot be negative: -3 [167] */
14 arr[-3] = 13;
15
16 /*
17 * Since the pointer may have been initialized with "arr + 3",
18 * subtracting from its address is allowed.
19 */
20 ptr[-3] = 13;
21 }
22