yohhoyの日記

技術的メモをしていきたい日記

atomic型と整数型のサイズ

プログラミング言語C/C++が標準で提供するatomic型は、必ずしも対応する整数型と同一サイズとは限らない。(とはいえlock-freeなatomic型であれば、ネイティブ命令でatomic操作が内部実装されるハズなので、整数型と同一サイズ/内部表現になると考えられる。)

C++11

JTC1/SC22/WG21 N3337 29.5/p9より引用。

9 [Note: The representation of an atomic specialization need not have the same size as its corresponding argument type. Specializations should have the same size whenever possible, as this reduces the effort required to port existing code. -- end note]

C11

JTC1/SC22/WG14 N1570 6.2.5/p27より引用。

27 Further, there is the _Atomic qualifier. The presence of the _Atomic qualifier designates an atomic type. The size, representation, and alignment of an atomic type need not be the same as those of the corresponding unqualified type. Therefore, this Standard explicitly uses the phrase "atomic, qualified or unqualified type" whenever the atomic version of a type is permitted along with the other qualified versions of a type. The phrase "qualified or unqualified type", without specific mention of atomic, does not include the atomic types.

関連URL