va_list bug

Jimen Ching jching@flex.com
Tue Jul 13 17:28:00 GMT 1999


On 13 Jul 1999, Alexandre Oliva wrote:
>Right.  On alpha (and many other architectures), void* != va_list.
>You just can't assume it works, and there's no easy work-around.

But it failed to compile, not crash the resulting binary.  Even if I cast
the void* to va_list, I still get a compiler error.  Since when did
standard C not allow one to cast void* to something else?  Or are you
suggesting that I use something like this?

	void *vp;
	va_list vl = *(va_list *)vp;

I didn't try this, maybe that would work?  Before, I would just cast it to
(va_list).  Independent of what va_list is typed as, casting to it should
be valid standard C.  I.e.

	void *vp;
	int i = (int) vp; /* ok? */
	va_list v2 = (va_list) vp; /* error? */

Yes, I loose information if sizeof(int) < sizeof(void*).  But that's not
the point.  It should still be valid, at the very least, it should not be
an error.

If this is not the case, please give me a reference to the ISO C standard,
that specifies the correct behavior.

Thanks.

--jc
--
Jimen Ching (WH6BRR)      jching@flex.com     wh6brr@uhm.ampr.org



More information about the Gcc-bugs mailing list