"a[++i] = i" vs "a[i] = ++i"

David Held dmd at wyntrmute.com
Mon Dec 23 12:39:21 PST 2013


On 12/21/2013 6:21 AM, bearophile wrote:
> aldanor:
>
>> So should this considered a bug then and be filed?
>
> I think so. I have a related EnhancementRequest open, but I have to
> close it down or modify it...
>
> Bye,
> bearophile

int mightUpdate(int& x)
{
     ...
     return x;
}

{
     ...
     a[mightUpdate(i)] = mightUpdate(i);
     ...
}

Is this also a bug?  How would the compiler know whether to emit a 
diagnostic for this case?

Dave



More information about the Digitalmars-d-learn mailing list