Subject: Re: GNU config.guess and netbsd{aout,elf,}
To: Charles M. Hannum <root@ihack.net>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: tech-toolchain
Date: 11/23/1999 15:14:00
In message <el2d7t0hku5.fsf@eniwetok.ihack.net>Charles M. Hannum writes
>
>Jonathan Stone <jonathan@DSG.Stanford.EDU> writes:
>
>> 	u_short VOLATILE rem;
>> 	rem = 0;
>> 	*(VOLATILE char *)&rem = buf[len-1];
>
>The result of dereferencing a casted pointer is explicitly
>implementation-defined in ANSI C.  It was never defined at all in K&R
>C.  So at best this is non-portable code.

Thanks, Charles. What I was hoping to get was a citation to a
standards paragraph.

The reason I'm asking is to educate the IRTF about the portabillity
issues of code they've been using for, oh, 20 years now.  That code
has, empiricallyh, been more portable and more reliable than the
alternatives. Until now.

Yes, the alternatives are obvious, but the above snippet was
consciously crafted to avoid knowing about host endian-ness,
when summing in the last byte of an odd-length Internet packet.


Myself, I think the most robust answer would be to fix egcs's
implementation-defined behaviour to be compatible with existing art
but that may require a significant change to egcs maintainers' outlook:-)