[Issue 1685] Array index is evaluated twice

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 23 06:37:26 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1685


casio_fifty at yahoo.com.hk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Linux                       |All




------- Comment #1 from casio_fifty at yahoo.com.hk  2007-11-23 08:37 -------
Can be reproduce on Windows with DMD too. Both v1.023 & v2.007 are affected. 

It seems that the line is interpreted as

/*1*/    a[f()]
/*2*/ +  cast(int)42L
/*3*/ -> a[f()]

f() is evaluated twice only when a downward cast is needed, so replacing 42L by
42.0 will trigger the 2nd f(), but simpler types such as bool and char won't.

Also affects other *= methods, and associative arrays.


-- 



More information about the Digitalmars-d-bugs mailing list