Movatterモバイル変換


[0]ホーム

URL:


Issue 2365 - WG21 CWG Issues
Title
Confusing specification for dynamic_cast
Status
cd5
Section
7.6.1.7 [expr.dynamic.cast]
Submitter
Shiyao Ma

Created on2017-02-08.00:00:00 last changed60 months ago

Messages

msg6379 (view)
Date: 2018-11-15.00:00:00

Proposed resolution (November, 2018):

Change 7.6.1.7 [expr.dynamic.cast] paragraphs 4-6 as follows:

If the value ofvis a null pointer value in the pointercase, the result is the null pointer value of typeT.

IfTis “pointer tocv1B” andvhas type “pointer tocv2D” such thatB is a base classofD, the result is a pointer to theuniqueB subobject of theD object pointedto byv, or a null pointer value ifvis a null pointer value. Similarly, ifT is...

Otherwise,vshall be a pointer to or a glvalue of apolymorphic type (11.7.3 [class.virtual]).

Ifv is a null pointer value, the result is anull pointer value.

msg6204 (view)
Date: 2019-02-15.00:00:00

[Accepted as a DR at the February, 2019 meeting.]

From editorialissue1453.

According to 7.6.1.7 [expr.dynamic.cast] paragraph 4,

If the value ofvis a null pointer value in the pointer case, the resultis the null pointer value of typeT.

Paragraph 5 deals with the case of a simple up-cast, where no runtimetype identification is required. Paragraph 6 says,

Otherwise,v shall be a pointer to or a glvalue of a polymorphictype (11.7.3 [class.virtual]).

This organization of the material makes it sound as if the requirementfor polymorphic class types does not apply if the argument is a nullpointer value, which, of course, cannot be determined at compile time. Theintent is that a null pointer value argument produces a null pointer valueresult, regardless of whether the relationship between the classes requiresruntime type identification or not, but that the requirement forpolymorphic classes applies for all casts that are not simple up-casts. Thewording should be clarified.

History
DateUserActionArgs
2020-12-15 00:00:00adminsetmessages: +msg6379
2020-12-15 00:00:00adminsetstatus: open -> cd5
2017-02-08 00:00:00admincreate

[8]ページ先頭

©2009-2025 Movatter.jp