Article View: comp.std.c
Article #3351Re: Struct hack one last time (one last time)
From: John F. Woods
Date: Sun, 10 Jan 1993 22:09
Date: Sun, 10 Jan 1993 22:09
35 lines
1933 bytes
1933 bytes
martin@mwtech.UUCP (Martin Weitzel) writes: >Which directly brings up the question if (or if not) for >any modifiable lvalue `x' and some `y' of the same type an >assignment > x = y; >may behave differently >as a bitwise copy > memcpy(&x, &y, sizeof x); >(For the pedantics: Assume the appropriate header is included >and the two objects do not overlap.) >To put it into the language of the standard: May some (otherwise >strictly conforming) program change its behavior if the above >two were switched. This has a definite answer: a conforming implementation may have x = y; behave differently from memcpy(&x, &y, sizeof(x)); If x and y are structure types, it is already settled (via a Request For Interpretation, I believe) that holes in a structure need not be copied by assignment; this could be exposed in an otherwise conforming program by memcmp(&x, &y, sizeof(x)) Another example (which is what I started with, until I remembered this clear example) would be pointers; I believe that there is no requirement that a pointer to an object have a unique representation, only that all pointers to the same object shall *compare* equal. In particular, segmentation and alignment concerns could cause there to be a preferred representation for a pointer (which could be enforced at assignment) but several possible ways to represent the same pointer (which might get calculated differently for different expressions, depending on the compiler's expedience).
Technical Details
Message-ID:
<20822@ksr.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!bogus.sura.net!darwin.sura.net!gatech!enterpoop.mit.edu!world!ksr!jfwReferences:
<1993Jan7.221207.13818@leland.Stanford.EDU> <1375@mwtech.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!bogus.sura.net!darwin.sura.net!gatech!enterpoop.mit.edu!world!ksr!jfw From: jfw@ksr.com (John F. Woods) Newsgroups: comp.std.c Subject: Re: Struct hack one last time (one last time) Message-ID: <20822@ksr.com> Date: 10 Jan 93 17:09:32 EST References: <1993Jan7.221207.13818@leland.Stanford.EDU> <1375@mwtech.UUCP> Sender: news@ksr.com Lines: 35