Strict aliasing rules for allocated objects

为君一笑 提交于 2019-12-06 01:38:43

An allocated object hasn't got any declared type, so its effective type is the type of the lvalue used for the access. With this single statement, p hasn't effective type:

#include <stdlib.h>
int *p = malloc(100 * sizeof(int));

Otherwise, it will have one with the next access:

/* Effective type of p: unsigned int */
*(unsigned int *)p = 20U;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!