blob: d591c6429d3557b52db1e9edc7e93072b2ef2e23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* $NetBSD: msg_116.c,v 1.6 2023/07/07 19:45:22 rillig Exp $ */
# 3 "msg_116.c"
// Test for message: illegal pointer subtraction [116]
/* lint1-extra-flags: -X 351 */
/*
* Subtracting an int pointer from a double pointer does not make sense.
* The result cannot be reasonably defined since it is "the difference of
* the subscripts of the two array elements" (C99 6.5.5p9), and these two
* pointers cannot point to the same array.
*/
_Bool
example(int *a, double *b)
{
/* expect+1: error: illegal pointer subtraction [116] */
return a - b > 0;
}
/*
* Even though signed char and unsigned char have the same size,
* their pointer types are still considered incompatible.
*
* C99 6.5.5p9
*/
_Bool
subtract_character_pointers(signed char *scp, unsigned char *ucp)
{
/* expect+1: error: illegal pointer subtraction [116] */
return scp - ucp > 0;
}
_Bool
subtract_const_pointer(const char *ccp, char *cp)
{
return ccp - cp > 0;
}
|