[net.lang.c] problem with unions

rich@hal.UUCP (K. Richard Magill) (06/04/86)

I have a problem saying what I want to say.  The basics look like:
(vax 4.2)

typedef union {
	char *c;
	int *i;
} U;

U f()
{
	return("mumble");
}

Which naturally is of the wrong type but casting the (char *) into
(U) doesn't work either.  This works but is ucky and -O doesn't rip out "one".

U f()
{
	U one;

	one.c = "mumble";
	return(one);
}

Am I missing something obvious?

K. Richard Magill
...decvax!cwruecmp!hal!rich