Bug 21402 – Operator evaluation

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-18T11:00:24Z
Last change time
2024-12-13T19:12:53Z
Assigned to
No Owner
Creator
Alex
Moved to GitHub: dmd#19826 →

Comments

Comment #0 by alex — 2020-11-18T11:00:24Z
I translated https://github.com/dlang/dmd/blob/a9e5b0db723f8edaf80df28f93257edf06d3f17b/test/runnable/evalorder.d#L59-L61 to work with ~= operator. during discussion of https://github.com/dlang/dlang.org/pull/2881 auto mul11ret3(T)(ref T s) { s ~= 11; return [3]; } void main() { static auto test3(int[] val) { (val ~= 7) ~= mul11ret3(val); return val; } assert(test3([2]) == [2,7,11,3]); } dmd on "your code here" failed with [2,11,7]
Comment #1 by simen.kjaras — 2020-11-18T13:59:08Z
This problem is worse than I expected. First I thought it was just a case of (val ~= 7) not returning by reference (A). Boy was I wrong. On Win10, dmd 2.094.0, -m32, I get [2,7,11] (B) - consistent with the above. On run.dlang.io, dmd, I get [2,11,7] (C) - also consistent with (A), but not with (B) On Win10, dmd 2.094.0, -m64, I get [2,7,11,3] (D) - not consistent with A, B, or C, but it's what we expect. Turns out, 2.094.0 is no longer the newest version, so I updated to 2.094.1, and I get the same behavior with both -m32 and -m64 as I used to get with -m64. run.dlang.org reports its version as 2.093 for dmd, dmd-beta, ldc-beta and ldc, and 2.091 for dmd-nightly. ldc and ldc-beta give the expected result of [2,7,11,3]. So... it's fixed?
Comment #2 by robert.schadek — 2024-12-13T19:12:53Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19826 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB