James Kanze
11/13/2008 9:55:00 AM
On Nov 13, 9:18 am, "Chris Becke" <chris.be...@gmail.com> wrote:
> "blargg" <blargg....@gishpuppy.com> wrote in
> messagenews:blargg.h4g-1211081238250001@192.168.1.4...
> > Chris Becke wrote:
> > without any casting. Also, if the standard required a
> > compiler to allow this, it would have to use the same
> > representation for all pointer types, rather than as
> > currently where it can use fewer bits for pointers to types
> > with alignment requirements more strict than char's.
> C99 still allows transformation to AND from void*
> void* x;
> int* y;
> x=y; // both are legal in C99. At least the latest versions of MSVC and GCC compile this fragment.
> y=x;
As does C++. The only difference is that C++ requires a
static_cast for the conversion from void*.
> That aside, I do get the problem with pointer representations.
> But, it seems a bit subversive to have a universal pointer
> type, and then disallow it being used as a universal pointer
> type.
The universal pointer type is void*, not void**.
> In its current form in c++, void* should have just been thrown
> out. It saves us a typecast only when casting to, not from
> void*s,
Which is probably a mistake---it should probably require the
conversion to be explicit in both directions.
> and c++ hasn't introduced any kind of indirection
> counting typecast, making void* worse than dangerous.
I'm not sure that I follow you here. C++ didn't change the
meaning of void* from that of C.
> All because some overly zelous individual decided that void**
> needs to be treated as a special case, definately note a
> pointer to a thing that is a void*.
What? void** (unlike void*) isn't a special case at all; it's a
pointer to a void*, and only to a void*. If I understand your
initial code, you wanted it to point to an int*.
And I don't know who you mean by "some overly zealous
individual". It's been that way in both C and C++ ever since
there was void.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34