blob: 498832cea7f3ea0160859ba829c298d6019b4fd8 (
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
|
/* $OpenBSD: test-2.c,v 1.1 2005/11/23 00:13:56 cloder Exp $ */
/*
* Placed in the public domain by Chad Loder <cloder@openbsd.org>.
*
* Test detection of right shift by too many bits.
*/
/* ARGSUSED */
int
main(int argc, char* argv[])
{
unsigned char c, d;
c = 'a';
d = c << 7; /* ok */
d = c >> 7; /* ok */
c <<= 7; /* ok */
c >>= 7; /* ok */
d = c << 8; /* ok */
d = c >> 8; /* right-shifting an 8-bit quantity by 8 bits */
c <<= 8; /* ok */
c >>= 8; /* right-shifting an 8-bit quantity by 8 bits */
d = c << 9; /* ok */
d = c >> 9; /* right-shifting an 8-bit quantity by 9 bits */
c <<= 9; /* ok */
c >>= 9; /* right-shifting/assign an 8-bit quantity by 9 bits */
d = c << 10; /* ok */
d = c >> 10; /* right-shifting an 8-bit quantity by 10 bits */
c <<= 10; /* ok */
c >>= 10; /* right-shifting/assign an 8-bit quantity by 10 bits */
d++;
return 0;
}
|