postincrement behaviour (differences between dmd and gdc)

bearophile bearophileHUGS at lycos.com
Wed Apr 20 03:58:13 PDT 2011


Iain Buclaw:

> 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.

Thank you for raising this topic again. In my opinion in a modern language, even a system language, this kind of undefined (and different across different compilers) is _not_ acceptable.
Another source of some undefined behaviours are function calls.

Two possible solutions for D:
- Turn such situations that lead to undefined behaviour into syntax errors; 
- Do define and standardize such behaviours, even if this may cause tiny performance losses on some CPUs.

Bye,
bearophile


More information about the Digitalmars-d mailing list