www.digitalmars.com         C & C++   DMDScript  

c++.beta - void* => Base* is convertable?bug?

reply nyra <nyra sohu.com> writes:
see following code:

struct Base { char c; };

void test(Base* some){
	std::cout<<"ok"<<std::endl;
}
int main(void){
     test((void*)0);
     return 0;
}


void* => Base* is convertable?

extract from Loki library.

nyra
Oct 06 2003
next sibling parent Heinz Saathoff <hsaat bre.ipnet.de> writes:
nyra schrieb...
 see following code:
 
 struct Base { char c; };
 
 void test(Base* some){
 	std::cout<<"ok"<<std::endl;
 }
 int main(void){
      test((void*)0);
      return 0;
 }
 
 
 void* => Base* is convertable?
This should not be convertable. That's the reason why NULL should be defined as #define NULL 0 instead of #define NULL (void*)0 I assume DMC allows this for backward compatibility? - Heinz
Oct 07 2003
prev sibling parent Ilya Minkov <minkov cs.tum.edu> writes:
I like it when it is possible to write NULL when i mean it instead of a 
stupid cast! A cast is not only more typing, it's also cluttered, 
hard-to-read code. It can really turn a neat function call into something.

I propose that the implicit void* -> any* convertion stays.

I don't even see where it could harm one. (without touching any 
religious issues...)

-eye


nyra wrote:
 see following code:
 
 struct Base { char c; };
 
 void test(Base* some){
     std::cout<<"ok"<<std::endl;
 }
 int main(void){
     test((void*)0);
     return 0;
 }
 
 
 void* => Base* is convertable?
 
 extract from Loki library.
 
 nyra
Oct 26 2003