Article View: fr.comp.lang.c
Article #15005Re: Struct/Union avec les memes champs
From: Pierre Habouzit
Date: Wed, 19 Oct 2005 12:58
Date: Wed, 19 Oct 2005 12:58
33 lines
2107 bytes
2107 bytes
Marc Boyer wrote:
> Le 19-10-2005, Pierre Habouzit <madcoder@debian.org> a �crit�:
>>> typedef struct {
>>> int i;
>>> union {
>>> char j;
>>> char k;
>>> };
>>> } foo;
>>
>>> assert( f.j == f.k); // Est-ce l�gal ? Si oui, ref ?
>> c'est l�gal, mais :
>> * vu ton union toujours vrai
>> * s�mantiquement faux.
>
> Non, je suis pas d'accord: soit c'est un UB (acc�s � f.k
> non initialis�), soit c'est vrai.
non, je maintiens, ca sera toujours vrai. en tout cas sur tout compilo qui
ne vient pas de mars.
j et k "d�signent" le meme emplacement m�moire, et ont le meme type.
donc pour toute instance I de ton type foo, I.j == I.k (et meme comme le
disait je ne sais plus qui &I.j == &I.k, ce qui est l'hypoth�se que je
prend dans ce post pour mes affirmations).
initialis� ou non.
--
�O� Pierre Habouzit
��O madcoder@debian.org
OOO http://www.madism.org
Technical Details
Message-ID:
<435642fd$0$21309$626a54ce@news.free.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!news.agarik.com!usenet-fr.net!proxad.net!infeed-4.proxad.net!nnrp3-1.free.fr!not-for-mailReferences:
<slrndlbo6u.9sr.Marc.Boyer@localhost.localdomain> <4355f8d5$0$623$626a14ce@news.free.fr> <slrndlcdoq.a9d.Marc.Boyer@localhost.localdomain>Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,eb7f26af12505976 X-Google-Attributes: gidf9822,public X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!news.agarik.com!usenet-fr.net!proxad.net!infeed-4.proxad.net!nnrp3-1.free.fr!not-for-mail Message-ID: <435642fd$0$21309$626a54ce@news.free.fr> From: Pierre Habouzit <madcoder@debian.org> Subject: Re: Struct/Union avec les memes champs Newsgroups: fr.comp.lang.c Date: Wed, 19 Oct 2005 14:58:37 +0200 References: <slrndlbo6u.9sr.Marc.Boyer@localhost.localdomain> <4355f8d5$0$623$626a14ce@news.free.fr> <slrndlcdoq.a9d.Marc.Boyer@localhost.localdomain> Organization: Polytechnique.org User-Agent: KNode/0.9.2 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit Lines: 33 NNTP-Posting-Date: 19 Oct 2005 14:58:37 MEST NNTP-Posting-Host: 81.57.219.236 X-Trace: 1129726717 nnrp3-1.free.fr 21309 81.57.219.236:54289 X-Complaints-To: abuse@proxad.net