Title
Zero-initialization of pointers
Status
cd1
Section
9.4 [dcl.init]
Submitter
Andrew Sawyer

Created on 2001-04-05.00:00:00 last changed 161 months ago

Messages

Date: 2001-10-15.00:00:00

[Moved to DR at 10/01 meeting.]

Date: 2001-04-15.00:00:00

Proposed resolution (04/01):

In 9.4 [dcl.init] paragraph 5, change

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

to

...set to the value 0 (zero), taken as an integral constant expression, converted to T; [footnote: as specified in 7.3.12 [conv.ptr], converting an integral constant expression whose value is 0 to a pointer type results in a null pointer value.]
Date: 2004-09-10.00:00:00

The intent of 9.4 [dcl.init] paragraph 5 is that pointers that are zero-initialized will contain a null pointer value. Unfortunately, the wording used,

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

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

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

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

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetstatus: dr -> wp
2002-05-10 00:00:00adminsetmessages: + msg675
2001-11-09 00:00:00adminsetstatus: ready -> dr
2001-05-20 00:00:00adminsetmessages: + msg475
2001-04-05 00:00:00admincreate