C语言中的undefined behavior系列(5) -- not compatible type

Two declarationsof the same object or function specify types that are not compatible(6.2.7).

char c = 'a';
char *pc = &c;
int *pi;
void *pv;
pi
= pv = pc; //这里没有编译错误或警告
//pv = pi =pc; //这样写的话会有一个warning a value of type "char *" cannot be assigned to an entity of type "int *"
*pi = 10; //undefined behavior

 

 

 

posted @ 2010-08-31 19:30  嗷嗷  阅读(493)  评论(0编辑  收藏  举报