Title
Unsolicited reading of trailing volatile members
Status
open
Section
9.2.9.2 [dcl.type.cv]
Submitter
Hubert Tong

Created on 2015-11-06.00:00:00 last changed 75 months ago

Messages

Date: 2016-11-15.00:00:00

Additional notes from the November, 2016 meeting:

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

Date: 2022-02-18.07:47:23

Consider:

  struct A {
    ~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 9.2.9.2 [dcl.type.cv] 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.
History
Date User Action Args
2018-02-27 00:00:00adminsetmessages: + msg5936
2015-11-06 00:00:00admincreate