Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 18, 2010 [Issue 3825] New: A bug-prone situation with AAs | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3825 Summary: A bug-prone situation with AAs Product: D Version: 2.040 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: sean@invisibleduck.org ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2010-02-18 12:26:51 PST --- import std.stdio; void main() { string[] words = ["how", "are", "you", "are"]; int[string] aa1; foreach (w; words) aa1[w] = ((w in aa1) ? (aa1[w] + 1) : 2); writeln(aa1); // Prints: [how:1,you:1,are:2] int[string] aa2; foreach (w; words) if (w in aa2) aa2[w]++; else aa2[w] = 2; writeln(aa2); // Prints: [how:2,you:2,are:3] } This can be a source of bugs in programs. I don't know if there are ways to help the programmer avoid this bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2012 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |yebblies@gmail.com Platform|x86 |All Version|2.040 |D1 & D2 AssignedTo|nobody@puremagic.com |yebblies@gmail.com Summary|A bug-prone situation with |AAs entries are default |AAs |initialized before the new | |value is evaluated OS/Version|Windows |All Severity|normal |major -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2012 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com --- Comment #1 from yebblies <yebblies@gmail.com> 2012-02-03 18:35:00 EST --- *** Issue 5021 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 09, 2012 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |luka8088@owave.net --- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-05-09 00:21:06 PDT --- *** Issue 8070 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 21, 2012 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 --- Comment #3 from bearophile_hugs@eml.cc 2012-06-21 00:10:43 PDT --- Yesterday I've wasted some hours to locate this problem again in one of my programs. I hope this bug will be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 29, 2012 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dawg@dawgfoto.de --- Comment #4 from yebblies <yebblies@gmail.com> 2012-10-30 00:26:23 EST --- *** Issue 7914 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 11, 2013 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2013-01-11 07:12:36 PST --- https://github.com/D-Programming-Language/dmd/pull/1465 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 12, 2013 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 --- Comment #6 from bearophile_hugs@eml.cc 2013-01-12 08:58:03 PST --- Hara, I am reading the discussions in Pull 1465, and I have to say I use this kind of code all the time: aa[x]++; It's very handy. It's similar to a Python defaultdict: >>> from collections import defaultdict >>> d = defaultdict(int) >>> x = 'c' >>> d[x] += 1 >>> d defaultdict(<type 'int'>, {'a': 1}) If you disallow that If you disallow that, I will have tons of broken code. And I have to replace: aa[x]++; With: if (x in aa) aa[x]++; else a[x] = 0; This makes D code longer, and it doesn't make it safer. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 04, 2013 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 --- Comment #7 from github-bugzilla@puremagic.com 2013-03-03 17:46:25 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d5aac8cc2bcc43e8753d889eff8e005f5c7443ce fix Issue 3825 - AAs entries are default initialized before the new value is evaluated https://github.com/D-Programming-Language/dmd/commit/4af794608d6a29a1b03216038bcab63658ea9d87 Merge pull request #1465 from 9rnsr/fix3825 Issue 3825 - AAs entries are default initialized before the new value is evaluated -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 04, 2013 [Issue 3825] AAs entries are default initialized before the new value is evaluated | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3825 --- Comment #8 from bearophile_hugs@eml.cc 2013-03-03 18:42:38 PST --- Woo, after more than three years now it seems to work correctly. Close? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation