On 02-Jun-10 4:03 AM, Sasha Khapyorsky wrote:
On 00:18 Wed 02 Jun     , Yevgeny Kliteynik wrote:

AFAIR (anytype *) to (void *) casting is not needed (doing implicitly)
in C and this is already part of some basic standards.

True, but the problem is not (anytype *) to (void *) casting.
It's the other way around: (void *) to (anytype *) casting.

It is the same meaning. Otherwise it would be useless.

No, it's not.
Casting TO void* is not dangerous - void* is just a "place holder".
Casting FROM void* is more dangerous - it means your program would
actually be using this pointer's content.

Right now gcc allows you to do implicit casting in both ways, g++ doesn't.

Try compiling this code:

#include <stdlib.h>
int main()
{
        void * v = NULL;
        int * t = NULL;
        v = t;
        t = v;
        return 0;
}

try.cc:7: error: invalid conversion from 'void*' to 'int*'

Here are more details:

  http://www2.research.att.com/~bs/bs_faq2.html#void-ptr


-- Yevgeny
Sasha


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to