🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15008

Re: Struct/Union avec les memes champs

#15008
From: Jean-Marc Bourguet
Date: Wed, 19 Oct 2005 13:08
36 lines
2067 bytes
Pierre Habouzit <madcoder@debian.org> writes:

> 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.

Quand on me demande si c'est "legal" (je n'aime trop ce terme), je
comprends "est-ce strictement conforme".  Et dans ce cas, si char est
signe, il est possible que la valeur non initialisee soit une "trap
value" (en particulier dans le cas ou on utilise une representation en
complement a 1 avec le "-0" qui trappe).

A+

-- 
Jean-Marc
FAQ de fclc:       http://www.isty-info.uvsq.fr/~rumeau/fclc
Site de usenet-fr: http://www.usenet-fr.news.eu.org
Technical Details
Message-ID: <pxbpsq1bqo7.fsf@news.bourguet.org>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-1.proxad.net!news14-e.free.fr!not-for-mail
References: <slrndlbo6u.9sr.Marc.Boyer@localhost.localdomain> <4355f8d5$0$623$626a14ce@news.free.fr> <slrndlcdoq.a9d.Marc.Boyer@localhost.localdomain> <435642fd$0$21309$626a54ce@news.free.fr>

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!news1.google.com!proxad.net!infeed-1.proxad.net!news14-e.free.fr!not-for-mail
Newsgroups: fr.comp.lang.c
Subject: Re: Struct/Union avec les memes champs
References: <slrndlbo6u.9sr.Marc.Boyer@localhost.localdomain> <4355f8d5$0$623$626a14ce@news.free.fr> <slrndlcdoq.a9d.Marc.Boyer@localhost.localdomain> <435642fd$0$21309$626a54ce@news.free.fr>
From: Jean-Marc Bourguet <jm@bourguet.org>
Message-ID: <pxbpsq1bqo7.fsf@news.bourguet.org>
Date: 19 Oct 2005 15:08:08 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
Lines: 36
Organization: Guest of ProXad - France
NNTP-Posting-Date: 19 Oct 2005 15:08:08 MEST
NNTP-Posting-Host: 213.131.238.28
X-Trace: 1129727288 news14-e.free.fr 31838 213.131.238.28:17967
X-Complaints-To: abuse@proxad.net