🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #153

Re: Scalars and Structs

#153
From: John Davison
Date: Wed, 12 Aug 1992 04:38
26 lines
1459 bytes
In article <1992Aug3.152558.16670@taumet.com> steve@taumet.com (Steve Clamage) writes:
>edelson@goudurix.inria.fr (Daniel Edelson) writes:
>
>>|> Am I correct in taking this to mean that there is no way to cast a
>>|> structure of known size to a scalar that just so happens to have the same
>>|> size (or vice versa)?
>
>>There's always:
>
>>	struct S s;
>>	int i;
>
>>	i = *(int*)&s;
>
>As I pointed out in an earlier article, this will fail at runtime if
>'int' requires stricter alignment than 'struct S'.

        And, of course, s cannot have the "register" storage-class specifier
(p. 59, American National Standard X3.159-1989).


-- 
NOTE: The opinions and other information contained herein are not to be
      construed as representative of Northern Telecom or any of its
      subsidiaries.  Please direct all electronic mail to 
                   =======> davisonj@ecn.purdue.edu. <=======
Technical Details
Message-ID: <1992Aug12.043849.27875@bnr.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!convex!news.utdallas.edu!corpgate!crchh327!davisonj
References: <1992Jul30.205601.13276@pasteur.Berkeley.EDU> <4036@seti.UUCP> <1992Aug3.152558.16670@taumet.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!convex!news.utdallas.edu!corpgate!crchh327!davisonj
From: davisonj@bnr.ca (John Davison)
Subject: Re: Scalars and Structs
Message-ID: <1992Aug12.043849.27875@bnr.ca>
Keywords: casts
Sender: news@bnr.ca (News on crchh327)
Nntp-Posting-Host: crchh7ab
Organization: Bell-Northern Research, Richardson, Tx.
References: <1992Jul30.205601.13276@pasteur.Berkeley.EDU> <4036@seti.UUCP> <1992Aug3.152558.16670@taumet.com>
Date: Wed, 12 Aug 1992 04:38:49 GMT
Lines: 26