🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1251

How is struct assignment defined (idle query)?

#1251
From: Jim Segrave
Date: Thu, 03 Sep 1992 12:13
26 lines
1150 bytes
I don't have access to a copy of the ANSI spec, hence my query:

Does ANSI say that structure assignment is done by member-wise copy or
by bit-wise copying?
The reason I ask is that if it is a bit-wise copy, then any padding in
a struct would have to have some (presumably inplementation defined)
value written to it so that the padding bytes could be copied.
I realise that most implementations will not suffer any ill effects
from the notional conversion of the following assignment:

struct a {...} a_one = { ...};
int some_func ()
{
  struct a a_two = a_one;


to:
  memcpy ((void *) &a_two, (void *) &a_one, sizeof (struct a));

but I wondered if this conveys the actual ANSI definition of struct
assignment.


--
Jim Segrave
Technical Details
Message-ID: <715547606snx@grendel.demon.co.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!grendel.demon.co.uk!jes

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
From: jes@grendel.demon.co.uk (Jim Segrave)
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!grendel.demon.co.uk!jes
Distribution: world
Subject: How is struct assignment defined (idle query)?
X-Mailer: cppnews $Revision: 1.14 $
Organization: None
Lines: 27
Date: Thu, 3 Sep 1992 12:13:26 +0000
Message-ID: <715547606snx@grendel.demon.co.uk>
Sender: usenet@gate.demon.co.uk