err.InvalidAddress5.d revision 2633:71bab08d24b2
1193323Sed/* 2193323Sed * CDDL HEADER START 3193323Sed * 4193323Sed * The contents of this file are subject to the terms of the 5193323Sed * Common Development and Distribution License (the "License"). 6193323Sed * You may not use this file except in compliance with the License. 7193323Sed * 8193323Sed * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9193323Sed * or http://www.opensolaris.org/os/licensing. 10193323Sed * See the License for the specific language governing permissions 11193323Sed * and limitations under the License. 12193323Sed * 13193323Sed * When distributing Covered Code, include this CDDL HEADER in each 14193323Sed * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15193323Sed * If applicable, add the following below this CDDL HEADER, with the 16193323Sed * fields enclosed by brackets "[]" replaced with your own identifying 17193323Sed * information: Portions Copyright [yyyy] [name of copyright owner] 18193323Sed * 19193323Sed * CDDL HEADER END 20198090Srdivacky */ 21198090Srdivacky 22193323Sed/* 23193323Sed * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24193323Sed * Use is subject to license terms. 25193323Sed */ 26193323Sed 27193323Sed#pragma ident "%Z%%M% %I% %E% SMI" 28193323Sed 29218893Sdim/* 30193323Sed * ASSERTION: 31193323Sed * Using integer arithmetic providing a non-aligned memory address will throw 32193323Sed * a runtime error. 33193323Sed * 34193323Sed * SECTION: Pointers and Arrays/Generic Pointers 35193323Sed * 36193323Sed * NOTES: 37193323Sed * This test doesn't apply to x86; for the time being, we're working 38193323Sed * around this with the preprocessor. 39193323Sed */ 40193323Sed 41193323Sed#pragma D option quiet 42193323Sed 43193323Sedint array[3]; 44193323Seduintptr_t uptr; 45193323Sedint *p; 46193323Sedint *q; 47193323Sedint *r; 48193323Sed 49193323SedBEGIN 50193323Sed{ 51193323Sed#ifdef __i386 52193323Sed exit(1); 53193323Sed#else 54193323Sed array[0] = 20; 55193323Sed array[1] = 40; 56198090Srdivacky array[2] = 80; 57193323Sed 58218893Sdim uptr = (uintptr_t) &array[0]; 59193323Sed 60193323Sed p = (int *) (uptr); 61193323Sed q = (int *) (uptr + 2); 62193323Sed r = (int *) (uptr + 3); 63193323Sed 64193323Sed printf("array[0]: %d\t*p: %d\n", array[0], *p); 65218893Sdim printf("array[1]: %d\t*q: %d\n", array[1], *q); 66193323Sed printf("array[2]: %d\t*r: %d\n", array[2], *r); 67193323Sed 68193323Sed exit(0); 69193323Sed#endif 70193323Sed} 71193323Sed 72193323SedERROR 73193323Sed{ 74193323Sed exit(1); 75218893Sdim} 76193323Sed