This is the mail archive of the 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: Functions that are CSEable but not pure

On 10/04/2012 08:45 AM, Jakub Jelinek wrote:
On Thu, Oct 04, 2012 at 10:42:59AM +0200, Richard Guenther wrote:
On Wed, Oct 3, 2012 at 9:00 PM, Jason Merrill <> wrote:
If the result is not needed, are we allowed to remove a call to this

No. Unless you know the same function has been already called.

Yes, we are. If we optimize away a use of the variable, we can also remove the call to the function. We can also hoist the call so its side-effects occur before other side-effects, as the standard only requires that the initialization of the variable occur some time between thread creation and the first use of the variable.

So - what's wrong with using pure? That it doesn't "feel" correct?

No, it can modify memory.

Right, that's the issue. The back end assumes that calls to pure functions won't clobber memory; calls to these functions can clobber arbitrary memory, but only on the first call.

I think the plan was for these functions not to return any value,

No, I'm talking about the wrapper function which returns a reference to the variable (as in my example).


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