Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jun 2005 13:59:22 +0300
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        Dag-Erling Sm?rgrav <des@des.no>, current@freebsd.org
Subject:   Re: [current tinderbox] failure on ...all...
Message-ID:  <20050610105922.GA79872@ip.net.ua>
In-Reply-To: <72420.1118396985@critter.freebsd.dk>
References:  <20050610094615.GC79474@ip.net.ua> <72420.1118396985@critter.freebsd.dk>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Fri, Jun 10, 2005 at 11:49:45AM +0200, Poul-Henning Kamp wrote:
> 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.
> 
Well, the above example isn't quite different from when compiling two
modules that use the same structure type t1 but one of them is compiled
with -fstruct_is_magic=t1.  :-)


Cheers,
-- 
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (FreeBSD)

iD8DBQFCqXKKqRfpzJluFF4RAnnNAJ9EqDvnkIvf16Pq2NrqCjTs8zSyxACfZtxs
D0qr9HdyiOJkU0dH/eATvVk=
=qtdv
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050610105922.GA79872>