DMD 0.164: Possible bug in order of evaluation
Klaus Oberhofer
oberhofer at users.sourceforge.net
Mon Aug 21 00:25:38 PDT 2006
Walter Bright <newshound at digitalmars.com> wrote in news:eca93v$ddt$1
@digitaldaemon.com:
> Klaus Oberhofer wrote:
>> While porting some C-Code to D I had a possible bug that has to do with
>> the order of evaluation of the post increment operator.
>> The following C sample
> [...]
>> testarray_b[i++] = 1U << (16 - i);
> [...]
>> Could someone confirm this as a bug ?
>
> In the source code, yes. Depending on order of evaluation of side
> effects is an error in D as well as an error in C and C++.
>
Thank you for the lesson, Walter :)
Under normal circumstances I stay away from such constructs like the devil
from holy water. But I converted parts of unarj.c to D, and this
wonderful piece of code is a good example for your recently proposed
new D coding style :)
My failure was, that I tried to stay away from the internals of unarj.
Never mind, I'm here to learn and this way I learn much about D and
as a side effect about the internals of dictionary coders.
Greets
Klaus
BTW, one of my C books states that ANSI C compliant compilers are not
allowed to move/discard code unless they can prove there are no
side effects. It further says that on non compliant compilers the behaviour
is undefined.
More information about the Digitalmars-d-bugs
mailing list