postincrement behaviour (differences between dmd and gdc)

spir denis.spir at gmail.com
Wed Apr 20 02:50:13 PDT 2011


On 04/20/2011 11:33 AM, Iain Buclaw wrote:
> This was partially discussed before some time ago -
> http://www.digitalmars.com/d/archives/digitalmars/D/postincrement_behaviour_differences_between_dmd_and_gdc_47334.html
>
>
> The following statement has different behaviours in dmd and gdc.
>
> int x;
> x = x++;
>
>
> Where the backend for DMD interprets it as:
>
>    tmp = x;
>    x++;
>    x = tmp;
>
> And the backend for GDC interprets it as:
>
>    x = x;
>    x++;
>
>
> Skipping all undefined behaviour/which one is correct talk, an alternative
> suggestion would be to treat such nonsensical code as an error - like "Cannot
> modify the value of a variable twice in the same expression." - as this kind
> of thing I would expect to be almost always a bug.

Very probable. Also, the dmd interpretation makes even less sense for me. At 
least, gdc performs what the probable intent is. But an error is certainly far 
better.

denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list