Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!purdue!i.cc.purdue.edu!j.cc.purdue.edu!pur-ee!uiucdcs!uxc.cso.uiuc.edu!ccvaxa!aglew From: aglew@ccvaxa.UUCP Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <28200105@ccvaxa> Date: 20 Feb 88 21:23:00 GMT References: <2710@mmintl.UUCP> Lines: 44 Nf-ID: #R:mmintl.UUCP:2710:ccvaxa:28200105:000:1511 Nf-From: ccvaxa.UUCP!aglew Feb 20 15:23:00 1988 >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)? Or does the receiving function have to strictly be declared >as receiving a like struct? (or is that just "a good idea" vs a true >restriction in the language?) > > -Barry Shein, Boston University Well, if this is portable I am really going to be surprised. Any language lawyers out there with a most recent X3J11? In my out of date copy, C.3.2.2 says something like "each argument is evaluated, and each formal parameter is assigned the value of the corresponding argument... If the number of arguments or their types after conversion do not agree with those of the formal parameters, the behavior is undefined". Of course, printf is variadic, "...", so type checking doesn't apply. Andy "Krazy" Glew. Gould CSD-Urbana. 1101 E. University, Urbana, IL 61801 aglew@gould.com - preferred, if you have nameserver aglew@gswd-vms.gould.com - if you don't aglew@gswd-vms.arpa - if you use DoD hosttable aglew%mycroft@gswd-vms.arpa - domains are supposed to make things easier? My opinions are my own, and are not the opinions of my employer, or any other organisation. I indicate my company only so that the reader may account for any possible bias I may have towards our products.