Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
June 11, 2009 [Issue 3064] New: Invalid array operation accepted, generates bad code | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3064 Summary: Invalid array operation accepted, generates bad code Product: D Version: 1.045 Platform: x86_64 URL: http://www.digitalmars.com/d/1.0/arrays.html OS/Version: Linux Status: NEW Keywords: accepts-invalid, wrong-code Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: matti.niemenmaa+dbugzilla@iki.fi The following compiles in DMD 1.045, but shouldn't: void main() { int[] a = [1,2]; int[] b = [1,2]; a[] += b; assert (b[0] == 1); assert (b[1] == 2); assert (a[0] == 2); assert (a[1] == 4); } Currently, the code compiles but the third assertion fails, since DMD generates code as though b were an int. Note that the following both compiles and doesn't assert: void main() { int[] a = [1,2]; int[] b = [1,2]; a[] += b; assert (b[0] == 1); assert (b[1] == 2); assert (a[0] == 1+*cast(int*)&b); assert (a[1] == 2+*cast(int*)&b); } This is, of course, nonsense. The error is in the line 'a[] += b': according to http://www.digitalmars.com/d/1.0/arrays.html "[t]he rvalue can be an expression consisting either of an array slice of the same length and type as the lvalue or an expression of the element type of the lvalue, in any combination." Thus the line is incorrect and should read 'a[] += b[]', and that indeed works. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 03, 2010 [Issue 3064] Invalid array operation accepted, generates bad code | ||||
---|---|---|---|---|
| ||||
Posted in reply to matti.niemenmaa+dbugzilla@iki.fi | http://d.puremagic.com/issues/show_bug.cgi?id=3064 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |FIXED --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-05-03 01:39:52 PDT --- Fixed DMD1.059 and 2.044 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 03, 2010 [Issue 3064] Invalid array operation accepted, generates bad code | ||||
---|---|---|---|---|
| ||||
Posted in reply to matti.niemenmaa+dbugzilla@iki.fi | http://d.puremagic.com/issues/show_bug.cgi?id=3064 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |bearophile_hugs@eml.cc Resolution|FIXED | --- Comment #2 from bearophile_hugs@eml.cc 2010-05-03 04:08:26 PDT --- Reopened, because this wrong code compiles still with dmd v2.044, the bug persists: void main() { int[] a = [1,2]; int[] b = [1,2]; a[] += b; assert (b[0] == 1); assert (b[1] == 2); assert (a[0] == 2); assert (a[1] == 4); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 03, 2010 [Issue 3064] Invalid array operation accepted, generates bad code | ||||
---|---|---|---|---|
| ||||
Posted in reply to matti.niemenmaa+dbugzilla@iki.fi | http://d.puremagic.com/issues/show_bug.cgi?id=3064 --- Comment #3 from Don <clugdbug@yahoo.com.au> 2010-05-03 04:34:59 PDT --- (In reply to comment #2) > Reopened, because this wrong code compiles still with dmd v2.044, the bug persists: > > void main() { > int[] a = [1,2]; > int[] b = [1,2]; > a[] += b; > assert (b[0] == 1); > assert (b[1] == 2); > assert (a[0] == 2); > assert (a[1] == 4); > } Oops, it's fixed only in my personal copy, not in the official DMD. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 01, 2010 [Issue 3064] Invalid array operation accepted, generates bad code | ||||
---|---|---|---|---|
| ||||
Posted in reply to matti.niemenmaa+dbugzilla@iki.fi | http://d.puremagic.com/issues/show_bug.cgi?id=3064 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2010-05-31 19:03:32 PDT --- http://www.dsource.org/projects/dmd/changeset/509 -- 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