Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!rice!rice!sun-spots-request From: brad@ds3.bradley.edu (Bradley E. Smith) Newsgroups: comp.sys.sun Subject: Union Problem on Sparc Keywords: Miscellaneous Message-ID: <1990Nov4.031554.3208@rice.edu> Date: 4 Nov 90 03:00:00 GMT Sender: sun-spots-request@rice.edu Organization: Sun-Spots Lines: 36 Approved: Sun-Spots@rice.edu Originator: spots@titan.rice.edu X-Sun-Spots-Digest: Volume 9, Issue 358, message 19 X-Original-Date: Wed, 17 Oct 90 21:51:28 GMT Hi, I realize that the program below is not quite right(or proper) but I am trying to move our 'pic' source from a VAX to a SUN SPARC. The below program works ok on a VAX, AT&T 3B2, IBM RT but dumps core on a SUN. I always thought that unions were passed by value. Anyways I need this program to work, or I will have to rewrite a bunch of things. Is it me or is the compiler bugging (FYI: 4.0.3 and 4.1 have the same problem, and gcc does the same thing). union u { int i; long l; char c; float f; char *cp; }; main() { union u x,z; x.i = 100; z.i = 99; printf("sizeof(u) = %d\n", sizeof(x)); printf("sizeof(int) = %d\n", sizeof(int)); (void) doit(x,z); (void) doit(0,0); exit(0); } doit(a,b) union u a; union u b; { (void) printf("%d, %d\n", a.i, b.i); }