Temporarily disable all purity for debug prints

dsimcha dsimcha at yahoo.com
Mon Apr 11 15:32:04 PDT 2011


On 4/11/2011 6:23 PM, bearophile wrote:
> One extra note: in GCC 4.6 there are compiler switches like -Wsuggest-attribute=const that generate suggestions for functions that are implicitly const (pure) but don't have a const attribute yet.
>
> Bye,
> bearophile

Interesting (and practical) idea.  The only problems I see are templated 
functions (for which pure, nothrow, etc. are so broken it's not even 
funny) and finding functions that could be marked as pure if the 
implicitly pure functions they call were marked as pure.  For example:

// Module 1:

// fun is implicitly pure
uint fun(uint num) {
     return num + 1;
}

// Module 2:

// gun is implicitly pure but the compiler can only flag this
// if it realizes fun is implicitly pure.
uint gun(uint num) {
     return fun(num) * 2;
}



More information about the Digitalmars-d mailing list