1 /* $NetBSD: msg_167.c,v 1.7 2024/03/30 16:47:45 rillig Exp $ */ 2 # 3 "msg_167.c" 3 4 // Test for message: array subscript %jd cannot be negative [167] 5 6 /* lint1-extra-flags: -X 351 */ 7 8 void example(int * ptr)9example(int *ptr) 10 { 11 int arr[6]; 12 13 /* expect+1: warning: array subscript -3 cannot be negative [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