gpt4 book ai didi

c++ - 别名漏洞是否适用于签名字符?

转载 作者:行者123 更新时间:2023-12-02 20:57:30 25 4
gpt4 key购买 nike

在 C++ 中,存在一个别名漏洞,它允许通过某些字符类型的指针读取或写入任何对象的对象表示。

这仅适用于charunsigned char还是也适用于signed char

最佳答案

不,该规定不适用于signed char

[basic.lval]

8 If a program attempts to access the stored value of an object through a glvalue of other than one of the following types the behavior is undefined:

  • [...]
  • a char, unsigned char, or std​::​byte type.

上面的引用包含与字符类型别名有关的最后一个项目符号。 signed char 被排除。

尽管如此,这也是主题的一部分 CWG Issue 350处理,因此可能会发生变化。考虑到问题所采取的方向,其目的是(最终,希望如此?)明确定义。

关于c++ - 别名漏洞是否适用于签名字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57653869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com