Title
Pointer interconvertibility with bit-fields
Status
open
Section
6.9.4 [basic.compound]
Submitter
Jay Ghiron

Created on 2026-06-07.00:00:00 last changed 2 days ago

Messages

Date: 2026-06-30.10:18:06

Possible resolution:

  1. Change in 6.9.4 [basic.compound] bullet 3.1 as follows:

    ... Every value of pointer type is one of the following:
    • a pointer to an a non-bit-field object or to a function (the pointer is said to point to the object or function), or
    • ...
  2. Change in 6.9.4 [basic.compound] paragraph 6 as follows:

    Two non-bit-field objects a and b are pointer-interconvertible if
    • they are the same object, or
    • one is a union object and the other is a non-static data member of that object (11.5 [class.union]), or
    • one is a standard-layout class object and the other is the first non-static data member of that object or any base class subobject of that object (11.4 [class.mem]), where the member is not declared after any bit-field (11.4.10 [class.bit]), or
    • there exists an object c such that a and c are pointer-interconvertible, and c and b are pointer-interconvertible.
    If two objects are pointer-interconvertible, then they have the same address, and it is possible to obtain a pointer to one from a pointer to the other via a reinterpret_cast (7.6.1.10 [expr.reinterpret.cast]). ...
  3. Change in 7.6.2.2 [expr.unary.op] paragraph 3 as follows:

    The operand of the unary & operator shall be an a non-bit-field lvalue of some type T. ...
  4. Change in 7.6.2.2 [expr.unary.op] paragraph 5 as follows:

    If & is applied to an lvalue of incomplete class type and the complete type declares operator&(), it is unspecified whether the operator has the built-in meaning or the operator function is called. The operand of & shall not be a bit-field.
  5. Change in 11.4.10 [class.bit] paragraph 3 as follows:

    [ Note: The address-of operator & shall not cannot be applied to a bit-field (7.6.2.2 [expr.unary.op]), so ; there are no pointers to bit-fields (6.9.4 [basic.compound]). A non-const reference shall not cannot bind to a bit-field (9.5.4 [dcl.init.ref]). -- end note]
Date: 2026-06-07.00:00:00

(From submission #916.)

Preventing the formation of pointers to bit-fields is inconsistently enforced. Also, it appears the wording makes v and v.x pointer-interconvertible in the following example, which is undesirable:

struct {
  int : 1;
  int x;
} v;
History
Date User Action Args
2026-06-29 21:51:14adminsetmessages: + msg8625
2026-06-07 00:00:00admincreate