cplusplus / CWG

Core Working Group
24 stars 7 forks source link

[basic.pre] p3 Whether bit-fields are objects? #213

Open xmh0511 opened 1 year ago

xmh0511 commented 1 year ago

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

[basic.pre] p3 says

An entity is a value, object, reference, structured binding, function, enumerator, type, class member, bit-field, template, template specialization, namespace, or pack.

This implies object and bit-field are different entities.

However, [basic.lval] p1.1 says

A glvalue is an expression whose evaluation determines the identity of an object or function.

Lacks the bit-field cases. A glvalue can be a bit-field in the standard.

Suggested resolution:

We might need to strip bit-field from [basic.pre] p3, and admits that a (named)bit-field is an object. Then, in every special rule, we just need to say the bit-field object

languagelawyer commented 1 year ago

I think https://github.com/cplusplus/draft/pull/4068#pullrequestreview-442593025 may be relevant here, «bit-field» may mean unnamed bit-field declaration which is not a class member

xmh0511 commented 1 year ago

Promote [class.mem.general-note] p2 to a normative rule is helpful here

A non-static data member of non-reference type other than an unnamed bit-field is a member subobject of a class object.

Then, we clear that bit-field is an object. When we refer to "object", we intend to mention all objects(including bit-field). If we refer to "named bit-field", we intend to mention a special object that is called bit-field.

frederick-vs-ja commented 1 year ago

~It's unclear to me whether unnamed bit-fields should be considered as entities. I guess that bit-field can be struck from [basic.pre] p3.~

It seems more convenient to consider unnamed bit-fieled as entities for the purpose of definition of common intial sequence ([class.mem.general] p23).