Title
Confusing specification for dynamic_cast
Status
open
Section
8.2.7 [expr.dynamic.cast]
Submitter
Shiyao Ma

Created on 2017-02-08.00:00:00, last changed 2017-02-08.00:00:00.

Messages

Date: 2017-02-08.00:00:00

From editorial issue 1453.

According to 8.2.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 cast 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 (13.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.

History
Date User Action Args
2017-02-08 00:00:00admincreate