[TUHS] C++ / Kernel
Nevin Liber
nevin at eviloverlord.com
Fri Aug 24 08:28:44 AEST 2018
On Thu, Aug 23, 2018 at 5:17 PM <ron at ronnatalie.com> wrote:
> This union was right in the middle of the buf struct:
>
> union {
> caddr_t b_addr; /* low order core address */
> int *b_words; /* words for clearing */
> struct filsys *b_filsys; /* superblocks */
> struct dinode *b_dino; /* ilist */
> daddr_t *b_daddr; /* indirect block */
> } b_un;
> There were a number of other places that did the same thing. It's
> OFFICIALLY now in undefined behavior by the standard (though of course that
> didn't exist in the BSD days) ,
> to store in one element of the union and retrieve it via another.
It was still kinda frowned upon in K&R1: "It is the responsibility of the
programmer to keep track of what type is currently stored in a union; the
results are machine dependent if something is stored as one type and
extracted as another."
--
Nevin ":-)" Liber <mailto:nevin at eviloverlord.com> +1-847-691-1404
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20180823/acc02fb7/attachment.html>
More information about the TUHS
mailing list