From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: tuhs-bounces@minnie.tuhs.org X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.1 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 26f63185 for ; Thu, 23 Aug 2018 22:29:38 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id 75D5DA1A87; Fri, 24 Aug 2018 08:29:37 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 1C6E2A1A1B; Fri, 24 Aug 2018 08:29:24 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 57718A1A1B; Fri, 24 Aug 2018 08:29:22 +1000 (AEST) Received: from mail-vk0-f54.google.com (mail-vk0-f54.google.com [209.85.213.54]) by minnie.tuhs.org (Postfix) with ESMTPS id E3D40A1A1A for ; Fri, 24 Aug 2018 08:29:21 +1000 (AEST) Received: by mail-vk0-f54.google.com with SMTP id v62-v6so2129729vkd.3 for ; Thu, 23 Aug 2018 15:29:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Htv9dSZkOImFXtv5BNlO92U3I5CJPh/bE5onkO4YuLA=; b=Lh6Mbuho880agt+Mo9xafCRIZgWfuk2VbAYDcj+2feuDeO03qtPxaF3FvyoJAyQ7ub 1IFxsz+ry0DCLIDBYMARQQYJTWZ2z8ZNATKY/2UkIa+UJG+2JBBEyZkomasdoeBKm5sy En5l8su3aqLBb9Nn3+fauD6a71dutsgA6Jeql4U1NEaCtWC8pFF9KFxK/2QqaANENzKd GS8kulVXpyK2mDJbOy2VpUcT0LJmTj8vTyNHFJW7xlIzM2Kf866VCevLGPN+yIYq5yp6 JvyVlFe1SZ9G3V3EFn5a1KfLA+vZYx+fyrfDo7vhLPvcROkggnsq8v3vPg55oES8Gio+ Bagg== X-Gm-Message-State: APzg51A/FYmMfn5fOPaKBowyG3YE0QaghhtBvKYcMYw9xiWlQHMdxV/q GGXbNVMKHD5N20dpSCMW/QXdCRMqDNXyZmy1VXtM9JWM X-Google-Smtp-Source: ANB0Vda4tQjrFWNf4VgnXz27yWKNgEQZd0GwoFxlO+fsqkk9H4T+rXwP9DIBuuo2x9WSt5keEUKRYA+uRy1nUqfIfzU= X-Received: by 2002:a1f:b745:: with SMTP id h66-v6mr5500809vkf.21.1535063360687; Thu, 23 Aug 2018 15:29:20 -0700 (PDT) MIME-Version: 1.0 References: <10c401d43aef$8be34870$a3a9d950$@ronnatalie.com> <151301d43b2f$07881ed0$16985c70$@ronnatalie.com> In-Reply-To: <151301d43b2f$07881ed0$16985c70$@ronnatalie.com> From: Nevin Liber Date: Thu, 23 Aug 2018 17:28:44 -0500 Message-ID: To: tuhs@minnie.tuhs.org Content-Type: multipart/alternative; boundary="0000000000005255be057421caf5" Subject: Re: [TUHS] C++ / Kernel X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --0000000000005255be057421caf5 Content-Type: text/plain; charset="UTF-8" On Thu, Aug 23, 2018 at 5:17 PM 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 +1-847-691-1404 --0000000000005255be057421caf5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Aug 23, 2018 at 5:17 PM <ron@ronnatalie.com> wrote:
This union was right in the middle of the buf struct:=

=C2=A0 =C2=A0 =C2=A0 =C2=A0 union {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 caddr_t b_addr;=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* low order core address */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 int *b_words;=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* words for clearing */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct filsys *b_filsys;=C2=A0 = =C2=A0 /* superblocks */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct dinode *b_dino;=C2=A0 =C2= =A0 =C2=A0 /* ilist */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 daddr_t *b_daddr;=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0/* indirect block */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 } b_un;
There were a number of other places that did the same thing.=C2=A0 =C2=A0It= '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.=C2=A0

It was still kinda frowned upon in K&R1: = =C2=A0"It is the responsibility of the programmer to keep track of wha= t type is currently stored in a=C2=A0union;= the results are machine dependent if something is stored as one type and e= xtracted as another."
--
=C2=A0Nevin "= :-)" Liber=C2=A0 <mailto:nevin@eviloverlord.com> =C2=A0+1-847-691-1404
--0000000000005255be057421caf5--