From owner-freebsd-hackers Wed Feb 21 8:14: 3 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from critter.freebsd.dk (flutter.freebsd.dk [212.242.40.147]) by hub.freebsd.org (Postfix) with ESMTP id 9149437B491 for ; Wed, 21 Feb 2001 08:13:55 -0800 (PST) (envelope-from phk@critter.freebsd.dk) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.1/8.11.1) with ESMTP id f1LGDZx02058; Wed, 21 Feb 2001 17:13:35 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: Warner Losh Cc: "Jacques A. Vidrine" , freebsd-hackers@FreeBSD.ORG Subject: Re: portability sanity check In-Reply-To: Your message of "Wed, 21 Feb 2001 08:53:57 MST." <200102211553.f1LFrvs07412@billy-club.village.org> Date: Wed, 21 Feb 2001 17:13:35 +0100 Message-ID: <2056.982772015@critter> From: Poul-Henning Kamp Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <200102211553.f1LFrvs07412@billy-club.village.org>, Warner Losh writes: >In message <20010221094228.A93221@hamlet.nectar.com> "Jacques A. Vidrine" writes: >: Likewise if the first member were a more complex data type, but >: nevertheless the same between the different structures. >: >: It seems safe to me, but I can't explain why :-) > >It is obfuscated 'C', but it is safe. The standard requires that >(void *) &foo == (void *) &foo->s and that if s were a complex >structure that it be laid out the same in all instances of s. So I >think that it is "safe" to do that. Safe, but stupid, since type-safety is lost when doing so. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message