On Tue, 25 Mar 2014 10:08:20 -0400, monarch_dodra <[email protected]> wrote:

On Tuesday, 25 March 2014 at 13:30:04 UTC, Steven Schveighoffer wrote:
How can we force these to be weak-pure? One option suggested is to add a hidden void * parameter that defaults to null, to force the issue. But I think future compilers may be smart enough to realize that can also be a strong-pure call.

Maybe instead of using null, we could use global junk?

//Global junk
struct WeakPure{int a;}
__gshared WeakPure dummyWeakPure;


//Signature
void weakPureFun(WeakPure* p = &dummyWeakPure)
{}


//Useage
weakPureFun();



AFAIK, the compiler should NOT be able to infer strong purity here. I don't know about performance effects though.

I think again, a sufficiently intelligent compiler could see that dummyWeakPure would not be used in the template, we likely would have to pass it to the underlying opaque function. I'd really like to avoid this option, if it's not going to be optimized down to the minimal case.

-Steve

Reply via email to