gcc optimization constant propagation
John Fine
johnsfine@verizon.net
Wed Mar 4 14:45:00 GMT 2009
charfi asma wrote:
>
> Why in the fist code, c is not considered as a constant (in spite that affich() does not change c)
>
>
I have no idea how deep into affich the compiler can look (for changes
to c). I expect/hope it looks as deep as it inlines.
But those operator<<() calls in affich go much deeper than you might be
thinking through. I expect the compiler should not and does not inline
that deep, nor check for changes to c that deep.
Maybe you want c to be a local variable, so as long as there isn't a
accessible copy of its address lying around, the compiler can assume it
isn't modified by code inside called functions.
More information about the Gcc-help
mailing list