Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing referenced type named "C" in section 2.2, "POD Data Types" #190

Open
tahonermann opened this issue Sep 4, 2024 · 7 comments
Open

Comments

@tahonermann
Copy link
Contributor

Section 2.2 "POD Data Types" states:

A member pointer type is treated exactly as if it were the C type described below.

The "described below" link references section 2.3, "Member Pointers". That section does not contain any prose but it does have two subsections, section 2.3.1, "Data Member Pointers" and section 2.3.2, Member Function Pointers", neither of which defines a type named "C".

Section 2.4, "Non-POD Class Types" uses the name "C" as a generic identifier for a class type. If this is the type intended by the "C type" reference, then the "described below" link should be updated to reference this section. I don't see an obvious way in which the "C" type described there fits with the "member pointer type is treated exactly as if it were the C type" wording though, so it seems that some other elucidation is still required.

@jensmaurer
Copy link

My guess is that "C type" refers to this C-style type definition presented further below:

struct {
    fnptr_t ptr;
    ptrdiff_t adj;
  };

@tahonermann
Copy link
Contributor Author

Thanks, Jens. That seems likely. There would still be a gap for pointers to data members though.

@jensmaurer
Copy link

jensmaurer commented Sep 4, 2024

A pointer to data member is explained to be an offset stored in a ptrdiff_t.

@tahonermann
Copy link
Contributor Author

Indeed, but the "A member pointer type is treated exactly as if it were the C type described below" wording doesn't differentiate between data members and member functions. It seems that "the C type described below" must be intended to refer to different parts of the prose; for pointers to data members, the C type is ptrdiff_t where as for pointers to member functions, the C type is the unnamed struct type below.

In 2.3.1 Data Member Pointers:

The basic ABI properties of data member pointer types are those of ptrdiff_t.

In 2.3.2 Member Function Pointers:

In all representations, the basic ABI properties of member function pointer types are those of the following class, where fnptr_t is the appropriate function-pointer type for a member function of this type:

struct {
  fnptr_t ptr;
  ptrdiff_t adj;
};

This would make sense as the intent. I think the wording can still be improved though.

@rjmccall
Copy link
Collaborator

rjmccall commented Sep 4, 2024

That is the intent, yes. I'm open to suggestions about how to improve the wording.

@zygoloid
Copy link
Contributor

Maybe just remove the "C":

A member pointer type is treated exactly as if it were the C type described below.

@tahonermann
Copy link
Contributor Author

Maybe just remove the "C":

That helps, but there are two types to choose from (for data members vs member functions). Perhaps:

A member pointer type is treated exactly as if it were one of the C types described below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants