This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Fixes to bootstrap from a C++ compiler (part 1)
Daniel Jacobowitz <drow@false.org> writes:
>> > (Personally, I've always viewed the implicit conversion from "void *" to
>> > other pointer types in C a bug in the type system and I try to avoid
>> > relying on it.)
>>
>> I'm on the same page as you. It is a hole in the type system
>> the C committee introduced for I don't know exactly why. I see
>> the implicit conversion void* -> T* a highly spurious programming
>> style. I would definitely recommend against it.
>
> In C++, you have new and delete, which have "magic" behavior in this
> area. When you use other memory allocators, the collection of
> otherwise unnecessary casts gets a bit old.
How about macros xnew(type) and xnew_n(type, n)? That would remove
some verbosity (and unify the two idioms type x = xmalloc(sizeof *x)
and type x = xmalloc(sizeof (type)).
--
Falk