Bug 15905 – Tuple Op Assignment Overload incorrect?

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-04-09T21:25:09Z
Last change time
2024-12-01T16:26:29Z
Assigned to
No Owner
Creator
Matthew Dudley
Moved to GitHub: phobos#10171 →

Comments

Comment #0 by pontifechs — 2016-04-09T21:25:09Z
I've come across some wonky behavior with a Tuple's *= operator in 2.071. Here's a sample: import std.stdio; import std.typecons; alias SomeStuff = Tuple!(float, "value"); void main() { auto bob = SomeStuff(-1.0f); // Prints: writeln(bob); // Tuple!(float, "value")(-1) bob.value *= -1; writeln(bob); // Tuple!(float, "value")(-1.00002) !!!! WRONG !!!! auto sue = SomeStuff(-1.0f); writeln(sue); // Tuple!(float, "value")(-1) sue.value = sue.value * -1; writeln(sue); // Tuple!(float, "value")(1) auto interesting = SomeStuff(-1.0f); writeln(interesting); // Tuple!(float, "value")(-1) interesting.value *= -2; writeln(interesting); // Tuple!(float, "value")(2) What? } I'm running Arch Linux with DMD 2.071. Downgrading to 2.070 produces the following correct output: $ dmd --version; dmd app.d; ./app DMD64 D Compiler v2.070 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright Tuple!(float, "value")(-1) Tuple!(float, "value")(1) Tuple!(float, "value")(-1) Tuple!(float, "value")(1) Tuple!(float, "value")(-1) Tuple!(float, "value")(2) Same cmd on 2.071 for reference. $ dmd --version; dmd app.d; ./app DMD64 D Compiler v2.071.0 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright Tuple!(float, "value")(-1) Tuple!(float, "value")(-1.00002) Tuple!(float, "value")(-1) Tuple!(float, "value")(1) Tuple!(float, "value")(-1) Tuple!(float, "value")(2)
Comment #1 by robert.schadek — 2024-12-01T16:26:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10171 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB