blob: 382d13148c2edd4975308751bec90c1915867dc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/* $NetBSD: msg_167.c,v 1.4 2022/06/16 16:58:36 rillig Exp $ */
# 3 "msg_167.c"
// Test for message: array subscript cannot be negative: %ld [167]
void
example(int *ptr)
{
int arr[6];
/* expect+1: warning: array subscript cannot be negative: -3 [167] */
arr[-3] = 13;
/*
* Since the pointer may have been initialized with "arr + 3",
* subtracting from its address is allowed.
*/
ptr[-3] = 13;
}
|