Skip to content

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

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.

Activity

  1. frederick-vs-ja commented on Jul 22, 2023

    @frederick-vs-ja

    We should address more cases (also said in #232 (comment)).

  2. frederick-vs-ja commented on Apr 16, 2024

    @frederick-vs-ja

    Addressed by CWG2879.

  3. changed the title [-][expr.const.cast] p9 does not have a corresponding formal wording[/-] [+]CWG2879 [expr.const.cast] p9 does not have a corresponding formal wording[/+] on Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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