Bug 12251 – Use of BigInts in triple operator too

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-25T04:58:00Z
Last change time
2014-02-28T10:06:49Z
Keywords
wrong-code
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-02-25T04:58:55Z
import std.stdio, std.bigint; bool b; void main() { int x1, x2; (b ? x1 : x2) += 1; writeln(x1, " ", x2); BigInt y1, y2; (b ? y1 : y2) += 1; writeln(y1, " ", y2); } Output: 0 1 0 0 Expected output: 0 1 0 1
Comment #1 by safety0ff.bugz — 2014-02-25T10:07:46Z
I think this is a wrong-code bug and not a phobos enhancement. If we manually change the the BigInts to lvalues we see the correct output. ------ Example ----- import std.stdio, std.bigint; bool b; void main() { int x1, x2; (b ? x1 : x2) += 1; writeln(x1, " ", x2); BigInt y1, y2; (b ? y1 : y2) += 1; writeln(y1, " ", y2); BigInt z1, z2; *(b ? &z1 : &z2) += 1; writeln(z1, " ", z2); } ------ Output ----- 0 1 0 0 0 1
Comment #2 by bearophile_hugs — 2014-02-25T10:39:30Z
(In reply to comment #1) > I think this is a wrong-code bug and not a phobos enhancement. OK, changed to a normal bug.
Comment #3 by peter.alexander.au — 2014-02-25T13:08:54Z
Also, changing the "b" to "false" fixes the issue, so it is definitely code gen. I've updated the component to DMD so the right people see this.
Comment #4 by safety0ff.bugz — 2014-02-26T01:00:57Z
(In reply to comment #3) > Also, changing the "b" to "false" fixes the issue, so it is definitely code > gen. Looks more like a front end issue to me: the output doesn't change between compilers and compiler settings.
Comment #5 by yebblies — 2014-02-28T05:34:22Z
This appears to be fixed.
Comment #6 by bearophile_hugs — 2014-02-28T10:00:30Z
(In reply to comment #5) > This appears to be fixed. Yes, closed. But I'd like to know what has fixed this issue (and perhaps some tests could be added to keep this fixed).
Comment #7 by yebblies — 2014-02-28T10:06:49Z
That's a good idea.