按此https://stackoverflow.com/a/1812932/1814023 writing one member of union and reading another member is undefined behavior.
并按此https://stackoverflow.com/a/11640603/1814023 type punning is allowed in C99 / C11
我对这两个帖子感到有点困惑,哪一个是正确的?需要帮助理解类型惩罚Vs访问union的成员 .
谢谢 .
1 回答
它是在C89中定义的实现:
在C99 / C11中,它是's allowed, although when it'的陷阱表示,该值是不确定的 .