别名漏洞是否适用于签名字符?
Does the aliasing loophole apply to signed characters?
在 C++ 中有一个别名漏洞,它允许通过某些字符类型的指针读取或写入任何对象的对象表示。
这仅适用于 char
和 unsigned 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++ 中有一个别名漏洞,它允许通过某些字符类型的指针读取或写入任何对象的对象表示。
这仅适用于 char
和 unsigned 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
, orstd::byte
type.
上面的引用包含与字符类型别名相关的最后一个项目符号。 signed char
被排除。
不过,这也是 CWG Issue 350 处理的主题的一部分,因此可能会发生变化。考虑到问题的发展方向,目的是(最终,希望如此?)明确定义。