Title
Missing required initialization in example
Status
cd1
Section
7.6.4 [expr.mptr.oper]
Submitter
Giovanni Bajo

Created on 2005-01-03.00:00:00 last changed 162 months ago

Messages

Date: 2005-10-15.00:00:00

[Voted into WP at October 2005 meeting.]

Date: 2005-04-15.00:00:00

Proposed resolution (April, 2005):

Change the example in 7.6.4 [expr.mptr.oper] paragraph 5 to read as follows:

    struct S {
        S() : i(0) { }
        mutable int i;
    };
    void f()
    {
        const S cs;
        int S::* pm = &S::i;   // pm refers to mutable member S::i
        cs.*pm = 88;           // ill-formed: cs is a const object
    }
Date: 2005-01-03.00:00:00

7.6.4 [expr.mptr.oper] paragraph 5 contains the following example:

    struct S {
        mutable int i;
    };
    const S cs;
    int S::* pm = &S::i;   // pm refers to mutable member S::i
    cs.*pm = 88;           // ill-formed: cs is a const object

The const object cs is not explicitly initialized, and class S does not have a user-declared default constructor. This makes the code ill-formed as per 9.4 [dcl.init] paragraph 9.

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2006-04-22 00:00:00adminsetstatus: dr -> wp
2005-10-22 00:00:00adminsetmessages: + msg1276
2005-10-22 00:00:00adminsetstatus: ready -> dr
2005-05-01 00:00:00adminsetmessages: + msg1137
2005-05-01 00:00:00adminsetstatus: open -> ready
2005-01-03 00:00:00admincreate