Skip to content

CWG2879 [expr.const.cast] p9 does not have a corresponding formal wording #342

Closed
cplusplus/draft
#7458
@xmh0511

Description

@xmh0511

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[expr.const.cast] p9 says

[Note 3: Some conversions which involve only changes in cv-qualification cannot be done using const_cast. For instance, conversions between pointers to functions are not covered because such conversions lead to values whose use causes undefined behavior. For the same reasons, conversions between pointers to member functions, and in particular, the conversion from a pointer to a const member function to a pointer to a non-const member function, are not covered.
— end note]

In general, the note means we forbid the conversion between pointer/reference to function type by using const_cast, however, there is no formal wording.

Suggested Resolution

Give the restriction to T, with the change

The result of the expression const_cast<T>(v) is of type T, T shall not be a pointer/reference to function types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions