This is the mail archive of the gcc-help@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: gcc optimization constant propagation


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.


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