Home | History | Annotate | Line # | Download | only in lint1
msg_167.c revision 1.4
      1 /*	$NetBSD: msg_167.c,v 1.4 2022/06/16 16:58:36 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 	/* expect+1: warning: array subscript cannot be negative: -3 [167] */
     12 	arr[-3] = 13;
     13 
     14 	/*
     15 	 * Since the pointer may have been initialized with "arr + 3",
     16 	 * subtracting from its address is allowed.
     17 	 */
     18 	ptr[-3] = 13;
     19 }
     20