Safety is not what you think

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 31 02:09:59 UTC 2024


On Tuesday, 30 January 2024 at 15:38:26 UTC, Paul Backus wrote:
> This definitely isn't allowed in C or C++. I wonder what the 
> rationale is for having this behavior in D?

It isn't allowed in C, but allowed in C++

https://godbolt.org/z/9xTPhsb5G

As for rationale... I don't know why it wouldn't be allowed? You 
clearly need an lvalue to use prefix ++, and the result is the 
value after adding one, so why can't it be bound to a reference? 
I don't see where the problem would arise.

-Steve


More information about the Digitalmars-d-learn mailing list