プログラミング言語Cにおけるヌルポインタ値の内部表現(≒ビット表現)に関して、標準規格では特に規定しておらずその内部表現は非ゼロであっても良い。*1
注意:定数値0
はヌルポインタ定数として解釈されるが、ここで言う “ヌルポインタの内部表現” とは関係が無い。(ソースコード上の0
はヌルポインタとなるが、そのヌルポインタの内部ビット表現が all-0 とは限らない。)
comp.lang.c FAQ list(日本語訳)にてマシンアーキテクチャ実例がいくつか挙げられている(一部引用)。本当にこの手の処理系が実在したというお話。
Q: Seriously, have any actual machines really used nonzero null pointers, or different representations for pointers to different types?
A: The Prime 50 series used segment 07777, offset 0 for the null pointer, at least for PL/I.
Some Honeywell-Bull mainframes use the bit pattern 06000 for (internal) null pointers.
The CDC Cyber 180 Series has 48-bit pointers consisting of a ring, segment, and offset. Most users (in ring 11) have null pointers of 0xB00000000000.
関連URL