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
原文地址:https://www.cnblogs.com/aoaoblogs/p/1813981.html