1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * ASSERTION: 31 * positive type conversion checks 32 * 33 * SECTION: Types, Operators, and Expressions/Type Conversions 34 * 35 * NOTES: not all type conversions are checked. A lot of this section 36 * is tested within other tests. 37 */ 38 39 #pragma D option quiet 40 41 unsigned int i; 42 char c; 43 short s; 44 long l; 45 long long ll; 46 47 BEGIN 48 { 49 /* char -> int */ 50 c = 'A'; 51 i = c; 52 printf("c is %c i is %d\n", c, i); 53 54 /* int -> char */ 55 56 i = 1601; 57 c = i; 58 printf("i is %d c is %c\n", i, c); 59 60 /* char -> short */ 61 c = 'A'; 62 s = c; 63 printf("c is %c s is %d\n", c, s); 64 65 /* short -> char */ 66 67 s = 1601; 68 c = s; 69 printf("s is %d c is %c\n", s, c); 70 71 /* int -> short */ 72 73 i = 1601; 74 s = i; 75 printf("i is %d s is %d\n", i, s); 76 77 /* short -> int */ 78 79 s = 1601; 80 i = s; 81 printf("s is %d i is %d\n", s, i); 82 83 /* int -> long long */ 84 85 i = 4294967295; 86 ll = i; 87 printf("i is %d ll is %x\n", i, ll); 88 89 /* long long -> int */ 90 91 ll = 8589934591; 92 i = ll; 93 printf("ll is %d i is %x\n", ll, i); 94 95 /* char -> long long */ 96 97 c = 'A'; 98 ll = c; 99 printf("c is %c ll is %x\n", c, ll); 100 101 /* long long -> char */ 102 103 ll = 8589934401; 104 c = ll; 105 printf("ll is %x c is %c\n", ll, c); 106 107 exit(0); 108 } 109 110