On Thu, Mar 05, 2009 at 11:39:45AM +0000, charfi asma wrote:
> intc;

> int main()
> 
> {
> 
> Calcul ca;
> 
> c=3;
> 
> ca.affich();
> 
> ca.inc(c);
> 
> cout << "the value of c is" << c << endl;
> 
> return 0;
> 
> }
[...]
> int main()
> 
> {
> 
> Calcul ca;
> 
> ca.affich();
> 
> c=3;
> 
> ca.inc(c);
> 
> cout << "the value of c is" << c << endl;
> 
> return 0;
> 
> }
> 
> Why in the fist code, c is not considered as a constant (in spite that
> affich() does not change c)

Because GCC does not currently do the necessary analysis to know that
affich() does not change c; it therefore makes the conservative
assumption that it does.

-Nathan

Reply via email to