This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112c. See for the official list.


2195. Unsolicited reading of trailing volatile members

Section:  []     Status: open     Submitter: Hubert Tong     Date: 2015-11-06


  struct A {
    double d;
    float f;

  struct B : A { volatile int i; };

  A foo(B *bp) { return *static_cast<A *>(bp); }

Is it okay for the memory associated with bp->i to be accessed by foo?

See also [] paragraph 5

The semantics of an access through a volatile glvalue are implementation-defined. If an attempt is made to access an object defined with a volatile-qualified type through the use of a non-volatile glvalue, the behavior is undefined.

Additional notes from the November, 2016 meeting:

See also national body comment CH2, addressed in March, 2017 by P0612R0.