blob: c2c46d9f5fe39577518674f0a8fa6d8a537425fa (
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: platform_ilp32_long.c,v 1.4 2023/07/08 15:26:25 rillig Exp $ */
# 3 "platform_ilp32_long.c"
/*
* Test features that only apply to platforms that have 32-bit int, long and
* pointer types and where size_t is unsigned long, not unsigned int.
*
* On these platforms, in portable mode (-p), the type 'int' is in some cases
* assumed to be only 24 bits wide, in order to detect conversions from
* 'long' (or more probably 'size_t') to 'int', which can lose accuracy.
*/
/* lint1-only-if: ilp32 long */
/* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */
int s32;
unsigned int u32;
long sl32;
unsigned long ul32;
void
convert_between_int_and_long(void)
{
/*
* The '-p' option enables checks that apply independently of the
* current platform, assuming that 'long' is always wider than 'int'.
* This assumption, when applied on its own, leads to wrong warnings
* that a 32-bit 'long' may lose accuracy when converted to a 32-bit
* 'int'.
*
* To avoid these, take a look at the actually possible values of the
* right-hand side, and if they fit in the left-hand side, don't warn.
*/
s32 = sl32;
sl32 = s32;
u32 = ul32;
ul32 = u32;
}
|