Path: utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <669@cresswell.quintus.UUCP> Date: 20 Feb 88 03:46:15 GMT References: <2635@calmasd.GE.COM> <28200092@ccvaxa> <496@ecrcvax.UUCP> <20003@bu-cs.BU.EDU> Organization: Quintus Computer Systems, Mountain View, CA Lines: 24 In article <20003@bu-cs.BU.EDU>, bzs@bu-cs.BU.EDU (Barry Shein) writes: : Does anyone have any problems with: : foo() : { : struct { double x; int i; } a; : : a.x = 3.1; : a.i = 12; : printf("%g %d\n",a); : } : : as an example of a legal, portable program (printf isn't necessary, : any function which takes multiple arguments possibly handed off as a : struct)? Unless I have completely misread the dpANS, this will not be legal ANSI C, and the reason for that is that it has never been portable. K&R say that elements of a structure are given increasing addresses (a.x is lower than a.i), but the order of arguments is NOT defined: printf() could easily expect its arguments in the opposite order. What is more, some C compilers pass struct arguments on another stack; this is common when "small" arguments are passed in registers. The Orion C compiler, for example, allocated arrays and structs in one stack, and scalars in another. (I got burned by this once; never again!)