Article View: comp.std.c++
Article #928Re: Conversions to/from void*, redux
From: Chip Salzenberg
Date: Sat, 09 Mar 1991 02:07
Date: Sat, 09 Mar 1991 02:07
50 lines
2555 bytes
2555 bytes
According to dhoyt@vx.acs.umn.edu:
>In article <27D5708A.29CF@tct.uucp>, chip@tct.uucp (Chip Salzenberg) writes...
>>[ANSI C requires |void*| and |char*| to be identically represented]
>
>The reason that ANSI made this true (mostly, anyway) is because there
>existed a huge body of code that depended on this equivalence.
This statement is patently false, as proven by the next statement,
which is true:
>K&R didn't have a void type in the first place
It is impossible for K&R programs to depend on |void*|, since they
don't mention |void*|.
Point 1: ANSI created |void*| explicitly for the purpose of holding
any data address whatsoever. That's why, for example, the first two
arguments to memcpy() are both of type |void*|. ANSI C++ cannot
change this most basic characteristic of |void*| without breaking
compatibility with many ANSI C programs and large portions of the ANSI
C library.
Point 2: The ARM promises that a |char*| may hold any data address
whatever. This is guaranteed in the section I quoted in the
referenced article, which asserts that a pointer to any object may be
cast to a pointer to any object of equal or smaller type, and then
back to its original type, without problem.
Conclusion: Since |void*| and |char*| must both be able to hold any
address, the C requirement that they have identical representations is
entirely reasonable for ANSI C++.
>This forces word machines, such as the Cray's, either 1) always create
>slow code ...
Please describe -- exactly -- how |void*|-|char*| equivalence forces
machines with word addressing into generating "slow code".
(Of course, on word-addressed machines, a |T*| is typically only one
word, while a |void*| is larger, to specify the exact byte within the
addressed word. But that would always be true, regardless of the
implementation of |char*|.)
>But what do I know?
An excellent question.
--
Chip Salzenberg at Teltronics/TCT <chip@tct.uucp>, <uunet!pdn!tct!chip>
"Most of my code is written by myself. That is why so little gets done."
-- Herman "HLLs will never fly" Rubin
Technical Details
Message-ID:
<27D8437B.F13@tct.uucp>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pdn!tscs!tct!chipReferences:
<71031@microsoft.UUCP> <27D5708A.29CF@tct.uucp> <3568@ux.acs.umn.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pdn!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.std.c++ Subject: Re: Conversions to/from void*, redux Keywords: Sun, C++ Message-ID: <27D8437B.F13@tct.uucp> Date: 9 Mar 91 02:07:54 GMT References: <71031@microsoft.UUCP> <27D5708A.29CF@tct.uucp> <3568@ux.acs.umn.edu> Organization: Teltronics/TCT, Sarasota, FL Lines: 50