From owner-freebsd-current@FreeBSD.ORG Fri Jun 10 09:49:55 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9387416A41C; Fri, 10 Jun 2005 09:49:55 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from pasmtp.tele.dk (pasmtp.tele.dk [193.162.159.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id 41B7743D1F; Fri, 10 Jun 2005 09:49:55 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (0x535c0e2a.sgnxx1.adsl-dhcp.tele.dk [83.92.14.42]) by pasmtp.tele.dk (Postfix) with ESMTP id 319DE1EC375; Fri, 10 Jun 2005 11:49:54 +0200 (CEST) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.4/8.13.3) with ESMTP id j5A9njDL072421; Fri, 10 Jun 2005 11:49:45 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Ruslan Ermilov From: "Poul-Henning Kamp" In-Reply-To: Your message of "Fri, 10 Jun 2005 12:46:15 +0300." <20050610094615.GC79474@ip.net.ua> Date: Fri, 10 Jun 2005 11:49:45 +0200 Message-ID: <72420.1118396985@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Dag-Erling Sm?rgrav , current@freebsd.org Subject: Re: [current tinderbox] failure on ...all... X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2005 09:49:55 -0000 In message <20050610094615.GC79474@ip.net.ua>, Ruslan Ermilov writes: >> struct t1 { int a; } x; >> struct t2 { int a; } y = { 42 }; >> x = y; >> >> The types `struct t1' and `struct t2' are not compatible and thus not >> assignable. See 6.2.7 and 6.5.16.1. >> >If you're to byte-copy say t1 to t2, is it guaranteed to work? That is, >do both types are guaranteed to have the same size and alignment of their >structure members? I'm pretty sure this is guaranteed, as lot of code >assumes this, for example, the sockaddr* structures. I do not belive that is guaranteed. (If it were the structs might as well have been made assignable). You need to make sure that the two definitions are covered by the exact same compilation conditions, and you can't tell if a compiler has an option along the lines of -fstruct_is_magic=t2 Which does weird things you don't know about. The fact that it mostly works (and that we rely on this) is a testament to the fact that compiler writers emply their destructive creativity elsewhere. -- 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.