...
In this noncompliant code example, the class member variable C
is not explicitly initialized by a ctor-initializer in the default constructor. Despite the local variable o
being default-initialized, the use of C
within the call to S::f()
results in the use evaluation of an object with indeterminate value, resulting in undefined behavior.
Code Block | ||||
---|---|---|---|---|
| ||||
class S { int C; public: int f(int I) const { return I + C; } }; void f() { S o; int i = o.f(10); } |
...