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

[intro.memory] What is a "field"? #1569

Closed
morinmorin opened this issue Mar 21, 2017 · 4 comments
Closed

[intro.memory] What is a "field"? #1569

morinmorin opened this issue Mar 21, 2017 · 4 comments
Assignees

Comments

@morinmorin
Copy link
Contributor

In [intro.memory] (the C++ memory model), there are several occurrences of the word "field":

  • p4: if all fields between them are also bit-fields of non-zero width.
  • p5: The field a and bit-fields d and e.ee are each separate memory locations, …

While that word is a popular terminology in programming (and in fact it is used in diagnostic messages in some C++ compilers), it is not a defined term in C++.

So would it be better to add a note saying '"field" means a non-static data member'?

@morinmorin
Copy link
Contributor Author

c.f.
Since the language C is so simple, these wordings are modified to use "member" in C11:

[intro.memory]

  • p4
    • C++17: a bit-field and an adjacent non-bit-field are in separate memory locations,
    • C11: A bit-field and an adjacent non-bit-field member are in separate memory locations.
  • p4
    • C++17: if they are separated by a non-bit-field declaration.
    • C11: if they are separated by a non-bit-field member declaration.
  • p4
    • C++17: if all fields between them are also bit-fields of non-zero width.
    • C11: if all members declared between them are also (non-zero-length) bit-fields,
  • p5
    • C++17: The field a and bit-fields d and e.ee are each separate memory locations,
    • C11: The member a, and bit-fields d and e.ee are each separate memory locations,

@jensmaurer
Copy link
Member

I agree this is an issue to be fixed, but the proposed fixes don't quite work, because C++ has static data members, and unnamed bit-fields are not non-static data members.

@jensmaurer
Copy link
Member

Ok, this refers to two mentions of "field" in notes, not in normative text, so we can be a bit more sloppy with using common, but not-otherwise-defined terms. p5 can easily use "member" (it's referring to a specific non-static data member), but p4 could either:

  • just say "member", which is correct, but does not represent the entire rule (but the note is phrased as if it were)
  • or say "if all non-static data members and unnamed bit-fields between them are bit-fields of nonzero width." which sounds a bit confused, but is complete and correct.

@morinmorin
Copy link
Contributor Author

unnamed bit-fields are not non-static data members.

I didn't know that, thanks for the correction!

this refers to two mentions of "field" in notes, not in normative text, so we can be a bit more sloppy with using common, but not-otherwise-defined terms.

Also, thanks for the explanation; now I understand the situation.

p4 could either:

  • just say "member", which is correct, but does not represent the entire rule (but the note is phrased as if it were)
  • or say "if all non-static data members and unnamed bit-fields between them are bit-fields of nonzero width." which sounds a bit confused, but is complete and correct.

Or put "and unnamed bit-fields" in parentheses to alleviate lengthy appearance slightly?

  • …, if all non-static data members (and unnamed bit-fields) between them are bit-fields of nonzero width.

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

2 participants