CWG Issue 497

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025年11月05日


497. Missing required initialization in example

Section: 7.6.4  [expr.mptr.oper]     Status: CD1     Submitter: Giovanni Bajo     Date: 03 Jan 2005

[Voted into WP at October 2005 meeting.]

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.5 [dcl.init] paragraph 9.

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
 (追記) } (追記ここまで)


AltStyle によって変換されたページ (->オリジナル) /