This is the mail archive of the egcs-bugs@egcs.cygnus.com mailing list for the EGCS project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: va_list bug


On Tue, Jul 13, 1999 at 02:27:26PM -1000, Jimen Ching wrote:
> 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.

On some architectures (powerpc comes to mind), va_list is a struct. 
You can't cast a scalar type to a struct.



Dan

/--------------------------------\  /--------------------------------\
|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         dan@debian.org         |  |       dmj+@andrew.cmu.edu      |
\--------------------------------/  \--------------------------------/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]