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

monarch_dodra monarchdodra at gmail.com
Tue Dec 24 05:37:08 PST 2013


On Tuesday, 24 December 2013 at 07:08:49 UTC, David Held wrote:
> Ok, let's make it more interesting...

The compiler is only supposed to error out on stuff that is 
actually illegal according to the language.

What you are doing is not *illegal*, it just produces 
un-specified behavior. The compiler has no obligation to error 
out on it, and may not even be *allowed* to. At best, it might be 
able to detect something wrong, and be allowed to warn you about 
it.

AFAIK, Walter is not exactly for documenting such behavior, but 
just for enforcing that all compilers adhere to the same behvior. 
EG: the "wrong" behavior will be the same on all platforms. This 
way, if your code works on a machine, it *should* work just fine 
on another.


More information about the Digitalmars-d-learn mailing list