struct S { S(int x_):x(x_){} int x; }; void f(struct S const * p); int g(void) { struct S const s(10); f(&s); return s.x; }
つーか分からないのは仕方ないか。ということで
struct S { S(int x_):x(x_){} int x; int getX() const { return x; } }; void f(struct S const * p); int h(int); int g(void) { struct S const s(10); h(s.getX()); f(&s); return s.getX(); }
vc8もgcc3.4.4も、分かってるんだか分かってないんだか分からないコードを吐く。
さらに、このコードの int x を const int x にすると、gccは読み直しをしなくなる。 これはsのconst修飾に依存しない。(あれれ?)