From owner-freebsd-current@FreeBSD.ORG Fri Jun 10 11:53:46 2005 Return-Path: X-Original-To: freebsd-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 1DB1516A41C; Fri, 10 Jun 2005 11:53:46 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.94]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7189343D1F; Fri, 10 Jun 2005 11:53:45 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226]) by rosebud.otenet.gr (8.13.4/8.13.4/Debian-1) with SMTP id j5ABrfS1019269; Fri, 10 Jun 2005 14:53:41 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) by orion.daedalusnetworks.priv (8.13.4/8.13.4) with ESMTP id j5ABreg8082106; Fri, 10 Jun 2005 14:53:40 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by orion.daedalusnetworks.priv (8.13.4/8.13.4/Submit) id j5ABrer9082105; Fri, 10 Jun 2005 14:53:40 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Fri, 10 Jun 2005 14:53:40 +0300 From: Giorgos Keramidas To: Ruslan Ermilov Message-ID: <20050610115340.GA81777@orion.daedalusnetworks.priv> References: <84dead720506091950779d1661@mail.gmail.com> <86oeae3d8f.fsf@xps.des.no> <84dead72050610001675a32c19@mail.gmail.com> <863brq3bbz.fsf@xps.des.no> <84dead7205061001534b9385b3@mail.gmail.com> <863brqy41j.fsf@xps.des.no> <20050610091624.GA35628@wombat.fafoe.narf.at> <20050610094615.GC79474@ip.net.ua> <20050610102813.GA81548@orion.daedalusnetworks.priv> <20050610110254.GB79872@ip.net.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050610110254.GB79872@ip.net.ua> Cc: Dag-Erling Sm?rgrav , freebsd-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 11:53:46 -0000 On 2005-06-10 14:02, Ruslan Ermilov wrote: >On Fri, Jun 10, 2005 at 01:28:13PM +0300, Giorgos Keramidas wrote: >> That would be very hard to guarantee if two different modules that use >> the types are compiled with different alignment options, right? >> >> /* header1.h */ >> struct t1 {short t1s; int t1a;}; >> >> /* header2.h */ >> struct t2 {short t2s; int t2a;}; >> >> /* module1.c */ >> #include "header1.h" >> struct t1 x; >> >> /* module2.c */ >> #include "header1.h" >> #include "header2.h" >> extern struct t1 x; >> struct t2 y; >> >> If the two modules are compiled with different options that may affect >> struct member alignment, how would one ensure that it is correct to >> use code like this in module.c? >> >> y.t2s = 10; >> y.t2a = 100; >> memcpy(&x, &y, sizeof(x)); >> >> Even the use of sizeof(x) is tricky here, since there is no guarantee >> that sizeof(x) < sizeof(y). > > And if both modules use the same t1 but compiled with different alignment > options, the memcpy() in module.c won't work either, even a simple assignment > could break. :-) Probably no. Two struct t1 objects have the same type and assignment between the two may be implemented as "element-at-a-time memcpy)", as mentioned in $6.2.6.1(6) and footnote (42) of the C99 standard. This may or may not break though, but I couldn't find any good reference to it.