質問するログイン新規登録

回答編集履歴

2

refinement

2020/11/25 06:00

投稿

yohhoy
yohhoy

スコア6191

answer CHANGED
@@ -10,6 +10,6 @@
10
10
  > An object pointer can be explicitly converted to an object pointer of a different type. When a prvalue `v` of object pointer type is converted to the object pointer type "pointer to cv `T`", the result is `static_­cast<cv T*>(static_­cast<cv void*>(v))`. [...]
11
11
 
12
12
  ----
13
- 本題からはそれますが、変換先の型のアライメント要件によっては「未規定(unspecified)のポインタ値」(≠ 未定義(undefined))となる可能性があります。[C++17 [static.cast]/13](https://timsong-cpp.github.io/cppwp/n4659/expr#static.cast-13)
13
+ 本題からはそれますが、変換先のオブジェクト`T`のアライメント要件によっては「未規定(unspecified)のポインタ値」(≠ 未定義(undefined))となる可能性があります。[C++17 [static.cast]/13](https://timsong-cpp.github.io/cppwp/n4659/expr#static.cast-13)
14
14
 
15
15
  > A prvalue of type "pointer to cv1 `void`" can be converted to a prvalue of type "pointer to cv2 `T`", where `T` is an object type and cv2 is the same cv-qualification as, or greater cv-qualification than, cv1. If the original pointer value represents the address `A` of a byte in memory and `A` does not satisfy the alignment requirement of `T`, then the resulting pointer value is unspecified.

1

appendix

2020/11/25 06:00

投稿

yohhoy
yohhoy

スコア6191

answer CHANGED
@@ -7,4 +7,9 @@
7
7
 
8
8
  また、異なるオブジェクト型へのポインタ間の変換それ自体はwell-definedです。[C++17 [expr.reinterpret.cast]/p7](https://timsong-cpp.github.io/cppwp/n4659/expr.reinterpret.cast#7)
9
9
 
10
- > An object pointer can be explicitly converted to an object pointer of a different type. When a prvalue `v` of object pointer type is converted to the object pointer type "pointer to cv `T`", the result is `static_­cast<cv T*>(static_­cast<cv void*>(v))`. [...]
10
+ > An object pointer can be explicitly converted to an object pointer of a different type. When a prvalue `v` of object pointer type is converted to the object pointer type "pointer to cv `T`", the result is `static_­cast<cv T*>(static_­cast<cv void*>(v))`. [...]
11
+
12
+ ----
13
+ 本題からはそれますが、変換先の型のアライメント要件によっては「未規定(unspecified)のポインタ値」(≠ 未定義(undefined))となる可能性があります。[C++17 [static.cast]/13](https://timsong-cpp.github.io/cppwp/n4659/expr#static.cast-13)
14
+
15
+ > A prvalue of type "pointer to cv1 `void`" can be converted to a prvalue of type "pointer to cv2 `T`", where `T` is an object type and cv2 is the same cv-qualification as, or greater cv-qualification than, cv1. If the original pointer value represents the address `A` of a byte in memory and `A` does not satisfy the alignment requirement of `T`, then the resulting pointer value is unspecified.