This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
[Accepted as a DR at the February, 2019 meeting.]
From editorial issue 1453.
According to 7.6.1.7 [expr.dynamic.cast] paragraph 4,
If the value of v is a null pointer value in the pointer case, the result is the null pointer value of type T.
Paragraph 5 deals with the case of a simple up-cast, where no runtime type identification is required. Paragraph 6 says,
Otherwise, v shall be a pointer to or a glvalue of a polymorphic type (11.7.3 [class.virtual]).
This organization of the material makes it sound as if the requirement for polymorphic class types does not apply if the argument is a null pointer value, which, of course, cannot be determined at compile time. The intent is that a null pointer value argument produces a null pointer value result, regardless of whether the relationship between the classes requires runtime type identification or not, but that the requirement for polymorphic classes applies for all casts that are not simple up-casts. The wording should be clarified.
Proposed resolution (November, 2018):
Change 7.6.1.7 [expr.dynamic.cast] paragraphs 4-6 as follows:
If the value of v is a null pointer value in the pointer case, the result is the null pointer value of type T.If T is “pointer to cv1 B” and v has type “pointer to cv2 D” such that B is a base class of D, the result is a pointer to the unique B subobject of the D object pointed to by v, or a null pointer value if v is a null pointer value. Similarly, if T is...
Otherwise, v shall be a pointer to or a glvalue of a polymorphic type (11.7.3 [class.virtual]).
If v is a null pointer value, the result is a null pointer value.