value computed is not used
Shigeya Suzuki
shigeya@foretune.co.jp
Mon Apr 20 02:20:00 GMT 1998
Since I built first egcs last year, I'm getting following warning if I
use -Wall:
value computed is not used.
Actually, the value is computed and used.
Following snippet demonstrates this:
------------------------------
class Cx {
private:
int m_v;
public:
Cx() : m_v(0) { };
void set(int z) { m_v = z; }
int eval(void) { return m_v; }
};
class Cy {
private:
Cx* m_x1;
Cx* m_x2;
Cx* m_x3;
public:
Cy() : m_x1(0), m_x2(0), m_x3(0) { };
void setx1(Cx* v) { m_x1 = v; }
void setx2(Cx* v) { m_x1 = v; }
void setx3(Cx* v) { m_x1 = v; }
void exec() {
for (m_x1 != 0 && m_x1->eval();
m_x2 != 0 && m_x2->eval();
m_x3 != 0 && m_x3->eval()) {
}
}
};
------------------------------
dream 18% g++ -Wall -c z.cpp
z.cpp: In method `void Cy::exec()':
z.cpp:25: warning: value computed is not used
z.cpp:28: warning: value computed is not used
------------------------------
Why this happen?
Shigeya Suzuki shigeya@foretune.co.jp
More information about the Gcc
mailing list