This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: constant propagation optimization


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]