1*a98ff317SPedro F. Giffuni /*
2*a98ff317SPedro F. Giffuni  * CDDL HEADER START
3*a98ff317SPedro F. Giffuni  *
4*a98ff317SPedro F. Giffuni  * This file and its contents are supplied under the terms of the
5*a98ff317SPedro F. Giffuni  * Common Development and Distribution License ("CDDL"), version 1.0.
6*a98ff317SPedro F. Giffuni  * You may only use this file in accordance with the terms of version
7*a98ff317SPedro F. Giffuni  * 1.0 of the CDDL.
8*a98ff317SPedro F. Giffuni  *
9*a98ff317SPedro F. Giffuni  * A full copy of the text of the CDDL should have accompanied this
10*a98ff317SPedro F. Giffuni  * source.  A copy of the CDDL is also available via the Internet at
11*a98ff317SPedro F. Giffuni  * http://www.illumos.org/license/CDDL.
12*a98ff317SPedro F. Giffuni  *
13*a98ff317SPedro F. Giffuni  * CDDL HEADER END
14*a98ff317SPedro F. Giffuni  */
15*a98ff317SPedro F. Giffuni 
16*a98ff317SPedro F. Giffuni /*
17*a98ff317SPedro F. Giffuni  * Copyright (c) 2012 by Delphix. All rights reserved.
18*a98ff317SPedro F. Giffuni  */
19*a98ff317SPedro F. Giffuni 
20*a98ff317SPedro F. Giffuni /*
21*a98ff317SPedro F. Giffuni  * Test execution-time casting between integer types of different size.
22*a98ff317SPedro F. Giffuni  */
23*a98ff317SPedro F. Giffuni 
24*a98ff317SPedro F. Giffuni #pragma D option quiet
25*a98ff317SPedro F. Giffuni 
26*a98ff317SPedro F. Giffuni int64_t x;
27*a98ff317SPedro F. Giffuni 
28*a98ff317SPedro F. Giffuni BEGIN
29*a98ff317SPedro F. Giffuni {
30*a98ff317SPedro F. Giffuni 	z = 0xfff0;
31*a98ff317SPedro F. Giffuni 
32*a98ff317SPedro F. Giffuni 	x = (int32_t)(int16_t)z;
33*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
34*a98ff317SPedro F. Giffuni 	x = (int32_t)(uint16_t)z;
35*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
36*a98ff317SPedro F. Giffuni 	x = (uint32_t)(int16_t)z;
37*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
38*a98ff317SPedro F. Giffuni 	x = (uint32_t)(uint16_t)z;
39*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
40*a98ff317SPedro F. Giffuni 	printf("\n");
41*a98ff317SPedro F. Giffuni 
42*a98ff317SPedro F. Giffuni 	x = (int16_t)(int32_t)z;
43*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
44*a98ff317SPedro F. Giffuni 	x = (int16_t)(uint32_t)z;
45*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
46*a98ff317SPedro F. Giffuni 	x = (uint16_t)(int32_t)z;
47*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
48*a98ff317SPedro F. Giffuni 	x = (uint16_t)(uint32_t)z;
49*a98ff317SPedro F. Giffuni 	printf("%16x %20d %20u\n", x, x, x);
50*a98ff317SPedro F. Giffuni 
51*a98ff317SPedro F. Giffuni 	exit(0);
52*a98ff317SPedro F. Giffuni }
53