Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


277. Zero-initialization of pointers

Section:9.5  [dcl.init]    Status:CD1    Submitter:Andrew Sawyer    Date:5 Apr 2001

[Moved to DR at 10/01 meeting.]

The intent of 9.5 [dcl.init] paragraph 5 is thatpointers that are zero-initialized will contain a null pointervalue. Unfortunately, the wording used,

...set to the value of 0 (zero) converted toT

does not match the requirements for creating a null pointervalue given in 7.3.12 [conv.ptr] paragraph 1:

Anull pointer constant is an integral constant expression(7.7 [expr.const]) rvalue of integer type that evaluates tozero. A null pointer constant can be converted to a pointer type; theresult is thenull pointer value of that type...

The problem is that the "value of 0" in the description ofzero-initialization is not specified to be an integral constantexpression. Nonconstant expressions can also have the value 0,and converting a nonconst 0 to pointer type need not result ina null pointer value.

Proposed resolution (04/01):

In 9.5 [dcl.init] paragraph 5, change

...set to the value 0 (zero) converted toT;

to

...set to the value 0 (zero), taken as an integral constantexpression, converted toT; [footnote: asspecified in 7.3.12 [conv.ptr], converting an integralconstant expression whose value is 0 to a pointer type resultsin a null pointer value.]



[8]ページ先頭

©2009-2026 Movatter.jp